@opentripplanner/map-popup 5.2.0-alpha.1 → 5.2.0-alpha.3
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/LICENSE +21 -0
- package/README.md +5 -0
- package/esm/index.js +23 -24
- package/esm/index.js.map +1 -1
- package/esm/styled.js +1 -1
- package/esm/styled.js.map +1 -1
- package/esm/util.js +5 -7
- package/esm/util.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +11 -30
- package/lib/index.js.map +1 -1
- package/lib/styled.js +1 -6
- package/lib/styled.js.map +1 -1
- package/lib/util.js +3 -9
- package/lib/util.js.map +1 -1
- package/package.json +9 -9
- package/src/MapPopup.story.tsx +12 -2
- package/src/__snapshots__/MapPopup.story.tsx.snap +68 -68
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 OpenTripPlanner Project
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/esm/index.js
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
import FromToLocationPicker from "@opentripplanner/from-to-location-picker";
|
|
3
|
-
import coreUtils from "@opentripplanner/core-utils";
|
|
3
|
+
import coreUtils from "@opentripplanner/core-utils";
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line prettier/prettier
|
|
4
6
|
|
|
5
7
|
import { FocusTrapWrapper } from "@opentripplanner/building-blocks";
|
|
6
8
|
import { flatten } from "flat";
|
|
7
9
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
8
10
|
import { Styled } from "@opentripplanner/base-map";
|
|
9
|
-
import { ViewStopButton } from "./styled";
|
|
11
|
+
import { ViewStopButton } from "./styled";
|
|
10
12
|
|
|
13
|
+
// Load the default messages.
|
|
11
14
|
import defaultEnglishMessages from "../i18n/en-US.yml";
|
|
12
|
-
import { makeDefaultGetEntityName } from "./util";
|
|
15
|
+
import { makeDefaultGetEntityName } from "./util";
|
|
16
|
+
|
|
17
|
+
// HACK: We should flatten the messages loaded above because
|
|
13
18
|
// the YAML loaders behave differently between webpack and our version of jest:
|
|
14
19
|
// - the yaml loader for webpack returns a nested object,
|
|
15
20
|
// - the yaml loader for jest returns messages with flattened ids.
|
|
16
|
-
|
|
17
21
|
export var defaultMessages = flatten(defaultEnglishMessages);
|
|
18
|
-
|
|
19
22
|
var generateLocation = function generateLocation(entity, name) {
|
|
20
23
|
// @ts-expect-error some of these values may be null, but that's ok
|
|
21
24
|
var entityLon = entity.lon,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
entityLat = entity.lat,
|
|
26
|
+
x = entity.x,
|
|
27
|
+
y = entity.y;
|
|
25
28
|
var lat = entityLat || y;
|
|
26
29
|
var lon = entityLon || x;
|
|
27
30
|
if (!lat || !lon) return null;
|
|
@@ -31,7 +34,6 @@ var generateLocation = function generateLocation(entity, name) {
|
|
|
31
34
|
name: name
|
|
32
35
|
};
|
|
33
36
|
};
|
|
34
|
-
|
|
35
37
|
var StationHubDetails = function StationHubDetails(_ref) {
|
|
36
38
|
var station = _ref.station;
|
|
37
39
|
return /*#__PURE__*/React.createElement(Styled.PopupRow, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
@@ -50,10 +52,9 @@ var StationHubDetails = function StationHubDetails(_ref) {
|
|
|
50
52
|
}
|
|
51
53
|
})));
|
|
52
54
|
};
|
|
53
|
-
|
|
54
55
|
var StopDetails = function StopDetails(_ref2) {
|
|
55
56
|
var id = _ref2.id,
|
|
56
|
-
|
|
57
|
+
setViewedStop = _ref2.setViewedStop;
|
|
57
58
|
return /*#__PURE__*/React.createElement(Styled.PopupRow, null, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
58
59
|
defaultMessage: defaultMessages["otpUi.MapPopup.stopId"],
|
|
59
60
|
description: "Displays the stop id",
|
|
@@ -69,35 +70,33 @@ var StopDetails = function StopDetails(_ref2) {
|
|
|
69
70
|
id: "otpUi.MapPopup.stopViewer"
|
|
70
71
|
})));
|
|
71
72
|
};
|
|
72
|
-
|
|
73
73
|
function entityIsStation(entity) {
|
|
74
74
|
return "bikesAvailable" in entity;
|
|
75
75
|
}
|
|
76
|
+
|
|
76
77
|
/**
|
|
77
78
|
* Renders a map popup for a stop, scooter, or shared bike
|
|
78
79
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
80
|
export function MapPopup(_ref3) {
|
|
82
81
|
var _entity$networks;
|
|
83
|
-
|
|
84
82
|
var _ref3$closePopup = _ref3.closePopup,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
closePopup = _ref3$closePopup === void 0 ? function () {} : _ref3$closePopup,
|
|
84
|
+
configCompanies = _ref3.configCompanies,
|
|
85
|
+
entity = _ref3.entity,
|
|
86
|
+
getEntityName = _ref3.getEntityName,
|
|
87
|
+
getEntityPrefix = _ref3.getEntityPrefix,
|
|
88
|
+
setLocation = _ref3.setLocation,
|
|
89
|
+
setViewedStop = _ref3.setViewedStop;
|
|
92
90
|
var intl = useIntl();
|
|
93
91
|
if (!entity) return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
94
92
|
var getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);
|
|
95
93
|
var name = getNameFunc(entity, configCompanies);
|
|
96
|
-
var stationNetwork = "networks" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0
|
|
94
|
+
var stationNetwork = "networks" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0 || (_entity$networks = entity.networks) === null || _entity$networks === void 0 ? void 0 : _entity$networks[0]));
|
|
97
95
|
var bikesAvailablePresent = entityIsStation(entity);
|
|
98
96
|
var entityIsStationHub = bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.bikesAvailable) !== undefined && !(entity !== null && entity !== void 0 && entity.isFloatingBike);
|
|
99
|
-
var stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code) || entity.id.split(":")[1] || entity.id;
|
|
97
|
+
var stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code) || entity.id.split(":")[1] || entity.id;
|
|
100
98
|
|
|
99
|
+
// Double quotes make the query invalid, so remove them from the id just in case
|
|
101
100
|
var id = "focus-".concat(encodeURIComponent(entity.id).replace(/%/g, ""), "-popup");
|
|
102
101
|
return /*#__PURE__*/React.createElement(Styled.MapOverlayPopup, null, /*#__PURE__*/React.createElement(FocusTrapWrapper, {
|
|
103
102
|
closePopup: closePopup,
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx"],"names":["React","useCallback","FromToLocationPicker","coreUtils","FocusTrapWrapper","flatten","FormattedMessage","useIntl","Styled","ViewStopButton","defaultEnglishMessages","makeDefaultGetEntityName","defaultMessages","generateLocation","entity","name","entityLon","lon","entityLat","lat","x","y","StationHubDetails","station","value","bikesAvailable","spacesAvailable","StopDetails","id","setViewedStop","stopId","entityIsStation","MapPopup","closePopup","configCompanies","getEntityName","getEntityPrefix","setLocation","intl","getNameFunc","stationNetwork","itinerary","getCompaniesLabelFromNetworks","networks","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","split","encodeURIComponent","replace"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AACA,OAAOC,oBAAP,MAAiC,0CAAjC;AACA,OAAOC,SAAP,MAAsB,6BAAtB,C,CAEA;;AAGA,SAASC,gBAAT,QAAiC,kCAAjC;AACA,SAASC,OAAT,QAAwB,MAAxB;AACA,SAASC,gBAAT,EAA2BC,OAA3B,QAA0C,YAA1C;AACA,SAASC,MAAT,QAAuB,2BAAvB;AAEA,SAASC,cAAT,QAA+B,UAA/B,C,CAEA;;AACA,OAAOC,sBAAP,MAAmC,mBAAnC;AACA,SAASC,wBAAT,QAAyC,QAAzC,C,CAEA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,eAA0C,GAAGP,OAAO,CAACK,sBAAD,CAA1D;;AAEP,IAAMG,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,MAAD,EAAiBC,IAAjB,EAAkC;AACzD;AACA,MAAaC,SAAb,GAAiDF,MAAjD,CAAQG,GA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B;AAA5B,IAXvB,EAcCe,aAAa,IAAI,CAACe,qBAAlB,iBACC,oBAAC,WAAD;AACE,IAAA,EAAE,EAAEd,MADN;AAEE,IAAA,aAAa,EAAE7B,WAAW,CAAC;AAAA,aAAM4B,aAAa,CAACf,MAAD,CAAnB;AAAA,KAAD,EAA8B,CAACA,MAAD,CAA9B;AAF5B,IAfF,EAsBCuB,WAAW,iBACV,oBAAC,MAAD,CAAQ,QAAR,qBACE,oBAAC,oBAAD;AACE,IAAA,KAAK,MADP;AAEE,IAAA,QAAQ,EAAExB,gBAAgB,CAACC,MAAD,EAASC,IAAT,CAF5B;AAGE,IAAA,WAAW,EAAEsB;AAHf,IADF,CAvBF,CADF,CADF;AAqCD;AAED,eAAeL,QAAf","sourcesContent":["import React, { useCallback } from \"react\";\nimport FromToLocationPicker from \"@opentripplanner/from-to-location-picker\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\n// eslint-disable-next-line prettier/prettier\nimport type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from \"@opentripplanner/types\";\n\nimport { FocusTrapWrapper } from \"@opentripplanner/building-blocks\";\nimport { flatten } from \"flat\";\nimport { FormattedMessage, useIntl } from \"react-intl\";\nimport { Styled } from \"@opentripplanner/base-map\";\n\nimport { ViewStopButton } from \"./styled\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\nimport { makeDefaultGetEntityName } from \"./util\";\n\n// HACK: We should flatten the messages loaded above because\n// the YAML loaders behave differently between webpack and our version of jest:\n// - the yaml loader for webpack returns a nested object,\n// - the yaml loader for jest returns messages with flattened ids.\nexport const defaultMessages: { [key: string]: string } = flatten(defaultEnglishMessages);\n\nconst generateLocation = (entity: Entity, name: string) => {\n // @ts-expect-error some of these values may be null, but that's ok\n const { lon: entityLon, lat: entityLat, x, y } = entity\n\n const lat = entityLat || y\n const lon = entityLon || x\n if (!lat || !lon) return null\n\n return { lat, lon, name };\n}\n\nconst StationHubDetails = ({ station }: { station: Station }) => {\n return (\n <Styled.PopupRow>\n <div>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.MapPopup.availableBikes\"]\n }\n description=\"Label text for the number of bikes available\"\n id=\"otpUi.MapPopup.availableBikes\"\n values={{ value: station.bikesAvailable }}\n />\n </div>\n <div>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.MapPopup.availableDocks\"]\n }\n description=\"Label text for the number of docks available\"\n id=\"otpUi.MapPopup.availableDocks\"\n values={{ value: station.spacesAvailable }}\n />\n </div>\n </Styled.PopupRow>\n )\n}\n\nconst StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {\n return (\n <Styled.PopupRow>\n <strong>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.stopId\"]}\n description=\"Displays the stop id\"\n id=\"otpUi.MapPopup.stopId\"\n values={{\n stopId: id\n }}\n />\n </strong>\n <ViewStopButton onClick={setViewedStop}>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.stopViewer\"]}\n description=\"Text for link that opens the stop viewer\"\n id=\"otpUi.MapPopup.stopViewer\"\n />\n </ViewStopButton>\n </Styled.PopupRow>\n )\n}\n\ntype Entity = Stop | Station\ntype Props = {\n closePopup?: (arg?: any) => void\n configCompanies?: ConfiguredCompany[];\n entity: Entity\n getEntityName?: (entity: Entity, configCompanies: Company[],) => string;\n getEntityPrefix?: (entity: Entity) => JSX.Element\n setLocation?: ({ location, locationType }: { location: Location, locationType: string }) => void;\n setViewedStop?: StopEventHandler;\n};\n\nfunction entityIsStation(entity: Entity): entity is Station {\n return \"bikesAvailable\" in entity\n}\n\n/**\n * Renders a map popup for a stop, scooter, or shared bike\n */\nexport function MapPopup({ closePopup = () => {}, configCompanies, entity, getEntityName, getEntityPrefix, setLocation, setViewedStop }: Props): JSX.Element {\n\n const intl = useIntl()\n if (!entity) return <></>\n\n const getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);\n const name = getNameFunc(entity, configCompanies);\n\n const stationNetwork = \"networks\" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks(entity?.networks || [], configCompanies) || entity?.networks?.[0]);\n\n const bikesAvailablePresent = entityIsStation(entity)\n const entityIsStationHub = bikesAvailablePresent && entity?.bikesAvailable !== undefined && !entity?.isFloatingBike;\n const stopId = !bikesAvailablePresent && entity?.code || entity.id.split(\":\")[1] || entity.id\n\n // Double quotes make the query invalid, so remove them from the id just in case\n const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, \"\")}-popup`\n\n return (\n <Styled.MapOverlayPopup>\n <FocusTrapWrapper closePopup={closePopup} id={id}>\n <Styled.PopupTitle>\n {getEntityPrefix && getEntityPrefix(entity)}\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.popupTitle\"]}\n description=\"Text for title of the popup, contains an optional company name\"\n id=\"otpUi.MapPopup.popupTitle\"\n values={{ name, stationNetwork }}\n />\n </Styled.PopupTitle>\n {/* render dock info if it is available */}\n {entityIsStationHub && <StationHubDetails station={entity} />}\n\n {/* render stop viewer link if available */}\n {setViewedStop && !bikesAvailablePresent && (\n <StopDetails\n id={stopId}\n setViewedStop={useCallback(() => setViewedStop(entity), [entity])}\n />\n )}\n\n {/* The \"Set as [from/to]\" ButtonGroup */}\n {setLocation && (\n <Styled.PopupRow>\n <FromToLocationPicker\n label\n location={generateLocation(entity, name)}\n setLocation={setLocation}\n />\n </Styled.PopupRow>\n )}\n </FocusTrapWrapper>\n \n </Styled.MapOverlayPopup>\n );\n}\n\nexport default MapPopup;"],"file":"index.js"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","FromToLocationPicker","coreUtils","FocusTrapWrapper","flatten","FormattedMessage","useIntl","Styled","ViewStopButton","defaultEnglishMessages","makeDefaultGetEntityName","defaultMessages","generateLocation","entity","name","entityLon","lon","entityLat","lat","x","y","StationHubDetails","_ref","station","createElement","PopupRow","defaultMessage","description","id","values","value","bikesAvailable","spacesAvailable","StopDetails","_ref2","setViewedStop","stopId","onClick","entityIsStation","MapPopup","_ref3","_entity$networks","_ref3$closePopup","closePopup","configCompanies","getEntityName","getEntityPrefix","setLocation","intl","Fragment","getNameFunc","stationNetwork","itinerary","getCompaniesLabelFromNetworks","networks","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","split","concat","encodeURIComponent","replace","MapOverlayPopup","PopupTitle","label","location"],"sources":["../src/index.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport FromToLocationPicker from \"@opentripplanner/from-to-location-picker\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\n// eslint-disable-next-line prettier/prettier\nimport type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from \"@opentripplanner/types\";\n\nimport { FocusTrapWrapper } from \"@opentripplanner/building-blocks\";\nimport { flatten } from \"flat\";\nimport { FormattedMessage, useIntl } from \"react-intl\";\nimport { Styled } from \"@opentripplanner/base-map\";\n\nimport { ViewStopButton } from \"./styled\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\nimport { makeDefaultGetEntityName } from \"./util\";\n\n// HACK: We should flatten the messages loaded above because\n// the YAML loaders behave differently between webpack and our version of jest:\n// - the yaml loader for webpack returns a nested object,\n// - the yaml loader for jest returns messages with flattened ids.\nexport const defaultMessages: { [key: string]: string } = flatten(defaultEnglishMessages);\n\nconst generateLocation = (entity: Entity, name: string) => {\n // @ts-expect-error some of these values may be null, but that's ok\n const { lon: entityLon, lat: entityLat, x, y } = entity\n\n const lat = entityLat || y\n const lon = entityLon || x\n if (!lat || !lon) return null\n\n return { lat, lon, name };\n}\n\nconst StationHubDetails = ({ station }: { station: Station }) => {\n return (\n <Styled.PopupRow>\n <div>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.MapPopup.availableBikes\"]\n }\n description=\"Label text for the number of bikes available\"\n id=\"otpUi.MapPopup.availableBikes\"\n values={{ value: station.bikesAvailable }}\n />\n </div>\n <div>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.MapPopup.availableDocks\"]\n }\n description=\"Label text for the number of docks available\"\n id=\"otpUi.MapPopup.availableDocks\"\n values={{ value: station.spacesAvailable }}\n />\n </div>\n </Styled.PopupRow>\n )\n}\n\nconst StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {\n return (\n <Styled.PopupRow>\n <strong>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.stopId\"]}\n description=\"Displays the stop id\"\n id=\"otpUi.MapPopup.stopId\"\n values={{\n stopId: id\n }}\n />\n </strong>\n <ViewStopButton onClick={setViewedStop}>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.stopViewer\"]}\n description=\"Text for link that opens the stop viewer\"\n id=\"otpUi.MapPopup.stopViewer\"\n />\n </ViewStopButton>\n </Styled.PopupRow>\n )\n}\n\ntype Entity = Stop | Station\ntype Props = {\n closePopup?: (arg?: any) => void\n configCompanies?: ConfiguredCompany[];\n entity: Entity\n getEntityName?: (entity: Entity, configCompanies: Company[],) => string;\n getEntityPrefix?: (entity: Entity) => JSX.Element\n setLocation?: ({ location, locationType }: { location: Location, locationType: string }) => void;\n setViewedStop?: StopEventHandler;\n};\n\nfunction entityIsStation(entity: Entity): entity is Station {\n return \"bikesAvailable\" in entity\n}\n\n/**\n * Renders a map popup for a stop, scooter, or shared bike\n */\nexport function MapPopup({ closePopup = () => {}, configCompanies, entity, getEntityName, getEntityPrefix, setLocation, setViewedStop }: Props): JSX.Element {\n\n const intl = useIntl()\n if (!entity) return <></>\n\n const getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);\n const name = getNameFunc(entity, configCompanies);\n\n const stationNetwork = \"networks\" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks(entity?.networks || [], configCompanies) || entity?.networks?.[0]);\n\n const bikesAvailablePresent = entityIsStation(entity)\n const entityIsStationHub = bikesAvailablePresent && entity?.bikesAvailable !== undefined && !entity?.isFloatingBike;\n const stopId = !bikesAvailablePresent && entity?.code || entity.id.split(\":\")[1] || entity.id\n\n // Double quotes make the query invalid, so remove them from the id just in case\n const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, \"\")}-popup`\n\n return (\n <Styled.MapOverlayPopup>\n <FocusTrapWrapper closePopup={closePopup} id={id}>\n <Styled.PopupTitle>\n {getEntityPrefix && getEntityPrefix(entity)}\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.popupTitle\"]}\n description=\"Text for title of the popup, contains an optional company name\"\n id=\"otpUi.MapPopup.popupTitle\"\n values={{ name, stationNetwork }}\n />\n </Styled.PopupTitle>\n {/* render dock info if it is available */}\n {entityIsStationHub && <StationHubDetails station={entity} />}\n\n {/* render stop viewer link if available */}\n {setViewedStop && !bikesAvailablePresent && (\n <StopDetails\n id={stopId}\n setViewedStop={useCallback(() => setViewedStop(entity), [entity])}\n />\n )}\n\n {/* The \"Set as [from/to]\" ButtonGroup */}\n {setLocation && (\n <Styled.PopupRow>\n <FromToLocationPicker\n label\n location={generateLocation(entity, name)}\n setLocation={setLocation}\n />\n </Styled.PopupRow>\n )}\n </FocusTrapWrapper>\n \n </Styled.MapOverlayPopup>\n );\n}\n\nexport default MapPopup;"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,OAAOC,oBAAoB,MAAM,0CAA0C;AAC3E,OAAOC,SAAS,MAAM,6BAA6B;;AAEnD;;AAGA,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,OAAO,QAAQ,MAAM;AAC9B,SAASC,gBAAgB,EAAEC,OAAO,QAAQ,YAAY;AACtD,SAASC,MAAM,QAAQ,2BAA2B;AAElD,SAASC,cAAc,QAAQ,UAAU;;AAEzC;AACA,OAAOC,sBAAsB,MAAM,mBAAmB;AACtD,SAASC,wBAAwB,QAAQ,QAAQ;;AAEjD;AACA;AACA;AACA;AACA,OAAO,IAAMC,eAA0C,GAAGP,OAAO,CAACK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,eAAe,qBACrBjE,KAAA,CAAAyB,aAAA,CAACrB,gBAAgB;IAACwC,UAAU,EAAEA,UAAW;IAACf,EAAE,EAAEA;EAAG,gBACjD7B,KAAA,CAAAyB,aAAA,CAACjB,MAAM,CAAC0D,UAAU,QACfnB,eAAe,IAAIA,eAAe,CAACjC,MAAM,CAAC,eAC3Cd,KAAA,CAAAyB,aAAA,CAACnB,gBAAgB;IACfqB,cAAc,EAAEf,eAAe,CAAC,2BAA2B,CAAE;IAC7DgB,WAAW,EAAC,gEAAgE;IAC5EC,EAAE,EAAC,2BAA2B;IAC9BC,MAAM,EAAE;MAAEf,IAAI,EAAJA,IAAI;MAAEqC,cAAc,EAAdA;IAAe;EAAE,CAClC,CACgB,CAAC,EAEnBK,kBAAkB,iBAAIzD,KAAA,CAAAyB,aAAA,CAACH,iBAAiB;IAACE,OAAO,EAAEV;EAAO,CAAE,CAAC,EAG5DsB,aAAa,IAAI,CAACoB,qBAAqB,iBACtCxD,KAAA,CAAAyB,aAAA,CAACS,WAAW;IACVL,EAAE,EAAEQ,MAAO;IACXD,aAAa,EAAEnC,WAAW,CAAC;MAAA,OAAMmC,aAAa,CAACtB,MAAM,CAAC;IAAA,GAAE,CAACA,MAAM,CAAC;EAAE,CACnE,CACF,EAGAkC,WAAW,iBACVhD,KAAA,CAAAyB,aAAA,CAACjB,MAAM,CAACkB,QAAQ,qBACd1B,KAAA,CAAAyB,aAAA,CAACvB,oBAAoB;IACnBiE,KAAK;IACLC,QAAQ,EAAEvD,gBAAgB,CAACC,MAAM,EAAEC,IAAI,CAAE;IACzCiC,WAAW,EAAEA;EAAY,CAC1B,CACc,CAED,CAEI,CAAC;AAE7B;AAEA,eAAeR,QAAQ","ignoreList":[]}
|
package/esm/styled.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
|
-
/* eslint-disable-next-line import/prefer-default-export */
|
|
3
2
|
|
|
3
|
+
/* eslint-disable-next-line import/prefer-default-export */
|
|
4
4
|
export var ViewStopButton = styled.button.withConfig({
|
|
5
5
|
displayName: "styled__ViewStopButton",
|
|
6
6
|
componentId: "sc-12v7ov3-0"
|
package/esm/styled.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"styled.js","names":["styled","ViewStopButton","button","withConfig","displayName","componentId"],"sources":["../src/styled.ts"],"sourcesContent":["import styled from \"styled-components\";\n\n/* eslint-disable-next-line import/prefer-default-export */\nexport const ViewStopButton = styled.button`\n background: none;\n border-bottom: none;\n border-left: 1px solid #000;\n border-right: none;\n border-top: none;\n color: #008;\n font-family: inherit;\n margin-left: 5px;\n padding-top: 0;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;;AAEtC;AACA,OAAO,IAAMC,cAAc,GAAGD,MAAM,CAACE,MAAM,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,qKAU1C","ignoreList":[]}
|
package/esm/util.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import coreUtils from "@opentripplanner/core-utils";
|
|
1
|
+
import coreUtils from "@opentripplanner/core-utils";
|
|
2
2
|
|
|
3
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
3
4
|
export function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
|
|
4
5
|
return function defaultGetEntityName(entity, configCompanies) {
|
|
5
6
|
var _entity$networks;
|
|
6
|
-
|
|
7
7
|
// TODO: Stop generating this / passing it to the car string? Is it needed?
|
|
8
8
|
// In English we say "Car: " instead
|
|
9
|
-
var stationNetworks = "networks" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0
|
|
10
|
-
var stationName = entity.name || entity.id;
|
|
9
|
+
var stationNetworks = "networks" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0 || (_entity$networks = entity.networks) === null || _entity$networks === void 0 ? void 0 : _entity$networks[0]));
|
|
10
|
+
var stationName = entity.name || entity.id;
|
|
11
|
+
// If the station name or id is a giant UUID (with more than 3 "-" characters)
|
|
11
12
|
// best not to show that at all. The company name will still be shown.
|
|
12
13
|
// Also ignore "Default Vehicle Type"
|
|
13
|
-
|
|
14
14
|
if ((stationName.match(/-/g) || []).length > 3 || stationName === "Default vehicle type") {
|
|
15
15
|
stationName = null;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
17
|
if ("isFloatingBike" in entity && entity.isFloatingBike) {
|
|
19
18
|
stationName = intl.formatMessage({
|
|
20
19
|
defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingBike"],
|
|
@@ -42,7 +41,6 @@ export function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
|
|
|
42
41
|
name: stationName
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
|
-
|
|
46
44
|
return stationName;
|
|
47
45
|
};
|
|
48
46
|
}
|
package/esm/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"util.js","names":["coreUtils","makeDefaultGetEntityName","intl","defaultEnglishMessages","defaultGetEntityName","entity","configCompanies","_entity$networks","stationNetworks","itinerary","getCompaniesLabelFromNetworks","networks","stationName","name","id","match","length","isFloatingBike","formatMessage","defaultMessage","description","isFloatingCar","company","isFloatingVehicle"],"sources":["../src/util.ts"],"sourcesContent":["import { Company, Station, Stop } from \"@opentripplanner/types\";\nimport { IntlShape } from \"react-intl\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\n// eslint-disable-next-line import/prefer-default-export\nexport function makeDefaultGetEntityName(\n intl: IntlShape,\n defaultEnglishMessages: { [key: string]: string }\n) {\n return function defaultGetEntityName(\n entity: Station | Stop,\n configCompanies: Company[]\n ): string | null {\n // TODO: Stop generating this / passing it to the car string? Is it needed?\n // In English we say \"Car: \" instead\n const stationNetworks =\n \"networks\" in entity &&\n (coreUtils.itinerary.getCompaniesLabelFromNetworks(\n entity?.networks || [],\n configCompanies\n ) ||\n entity?.networks?.[0]);\n let stationName: string | null = entity.name || entity.id;\n // If the station name or id is a giant UUID (with more than 3 \"-\" characters)\n // best not to show that at all. The company name will still be shown.\n // Also ignore \"Default Vehicle Type\"\n if (\n (stationName.match(/-/g) || []).length > 3 ||\n stationName === \"Default vehicle type\"\n ) {\n stationName = null;\n }\n\n if (\"isFloatingBike\" in entity && entity.isFloatingBike) {\n stationName = intl.formatMessage(\n {\n defaultMessage: defaultEnglishMessages[\"otpUi.MapPopup.floatingBike\"],\n description: \"Popup title for a free-floating bike\",\n id: \"otpUi.MapPopup.floatingBike\"\n },\n { name: stationName }\n );\n } else if (\"isFloatingCar\" in entity && entity.isFloatingCar) {\n stationName = intl.formatMessage(\n {\n defaultMessage: defaultEnglishMessages[\"otpUi.MapPopup.floatingCar\"],\n description: \"Popup title for a free-floating car\",\n id: \"otpUi.MapPopup.floatingCar\"\n },\n {\n company: stationNetworks,\n name: stationName\n }\n );\n } else if (\"isFloatingVehicle\" in entity && entity.isFloatingVehicle) {\n // assumes that all floating vehicles are E-scooters\n stationName = intl.formatMessage(\n {\n defaultMessage:\n defaultEnglishMessages[\"otpUi.MapPopup.floatingEScooter\"],\n description: \"Popup title for a free-floating e-scooter\",\n id: \"otpUi.MapPopup.floatingEScooter\"\n },\n { name: stationName }\n );\n }\n return stationName;\n };\n}\n"],"mappings":"AAEA,OAAOA,SAAS,MAAM,6BAA6B;;AAEnD;AACA,OAAO,SAASC,wBAAwBA,CACtCC,IAAe,EACfC,sBAAiD,EACjD;EACA,OAAO,SAASC,oBAAoBA,CAClCC,MAAsB,EACtBC,eAA0B,EACX;IAAA,IAAAC,gBAAA;IACf;IACA;IACA,IAAMC,eAAe,GACnB,UAAU,IAAIH,MAAM,KACnBL,SAAS,CAACS,SAAS,CAACC,6BAA6B,CAChD,CAAAL,MAAM,aAANA,MAAM,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ED,IAAI,EAAED;MAAY,CACtB,CAAC;IACH;IACA,OAAOA,WAAW;EACpB,CAAC;AACH","ignoreList":[]}
|
package/lib/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHand
|
|
|
3
3
|
export declare const defaultMessages: {
|
|
4
4
|
[key: string]: string;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
type Entity = Stop | Station;
|
|
7
|
+
type Props = {
|
|
8
8
|
closePopup?: (arg?: any) => void;
|
|
9
9
|
configCompanies?: ConfiguredCompany[];
|
|
10
10
|
entity: Entity;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAiBpH,eAAO,MAAM,eAAe,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAoC,CAAC;AAgE1F,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAiBpH,eAAO,MAAM,eAAe,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAoC,CAAC;AAgE1F,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAA;AAC5B,KAAK,KAAK,GAAG;IACX,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;IAChC,eAAe,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,KAAM,MAAM,CAAC;IACxE,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,GAAG,CAAC,OAAO,CAAA;IACjD,WAAW,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACjG,aAAa,CAAC,EAAE,gBAAgB,CAAC;CAClC,CAAC;AAMF;;GAEG;AACH,wBAAgB,QAAQ,CAAC,EAAE,UAAqB,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAsD3J;AAED,eAAe,QAAQ,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,45 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.MapPopup = MapPopup;
|
|
9
|
-
exports.
|
|
10
|
-
|
|
8
|
+
exports.defaultMessages = exports.default = void 0;
|
|
11
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
-
|
|
13
10
|
var _fromToLocationPicker = _interopRequireDefault(require("@opentripplanner/from-to-location-picker"));
|
|
14
|
-
|
|
15
11
|
var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
|
|
16
|
-
|
|
17
12
|
var _buildingBlocks = require("@opentripplanner/building-blocks");
|
|
18
|
-
|
|
19
13
|
var _flat = require("flat");
|
|
20
|
-
|
|
21
14
|
var _reactIntl = require("react-intl");
|
|
22
|
-
|
|
23
15
|
var _baseMap = require("@opentripplanner/base-map");
|
|
24
|
-
|
|
25
16
|
var _styled = require("./styled");
|
|
26
|
-
|
|
27
17
|
var _enUS = _interopRequireDefault(require("../i18n/en-US.yml"));
|
|
28
|
-
|
|
29
18
|
var _util = require("./util");
|
|
30
|
-
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
|
+
// eslint-disable-next-line prettier/prettier
|
|
34
22
|
|
|
35
23
|
// Load the default messages.
|
|
24
|
+
|
|
36
25
|
// HACK: We should flatten the messages loaded above because
|
|
37
26
|
// the YAML loaders behave differently between webpack and our version of jest:
|
|
38
27
|
// - the yaml loader for webpack returns a nested object,
|
|
39
28
|
// - the yaml loader for jest returns messages with flattened ids.
|
|
40
|
-
const defaultMessages = (0, _flat.flatten)(_enUS.default);
|
|
41
|
-
exports.defaultMessages = defaultMessages;
|
|
42
|
-
|
|
29
|
+
const defaultMessages = exports.defaultMessages = (0, _flat.flatten)(_enUS.default);
|
|
43
30
|
const generateLocation = (entity, name) => {
|
|
44
31
|
// @ts-expect-error some of these values may be null, but that's ok
|
|
45
32
|
const {
|
|
@@ -57,7 +44,6 @@ const generateLocation = (entity, name) => {
|
|
|
57
44
|
name
|
|
58
45
|
};
|
|
59
46
|
};
|
|
60
|
-
|
|
61
47
|
const StationHubDetails = ({
|
|
62
48
|
station
|
|
63
49
|
}) => {
|
|
@@ -77,7 +63,6 @@ const StationHubDetails = ({
|
|
|
77
63
|
}
|
|
78
64
|
})));
|
|
79
65
|
};
|
|
80
|
-
|
|
81
66
|
const StopDetails = ({
|
|
82
67
|
id,
|
|
83
68
|
setViewedStop
|
|
@@ -97,15 +82,13 @@ const StopDetails = ({
|
|
|
97
82
|
id: "otpUi.MapPopup.stopViewer"
|
|
98
83
|
})));
|
|
99
84
|
};
|
|
100
|
-
|
|
101
85
|
function entityIsStation(entity) {
|
|
102
86
|
return "bikesAvailable" in entity;
|
|
103
87
|
}
|
|
88
|
+
|
|
104
89
|
/**
|
|
105
90
|
* Renders a map popup for a stop, scooter, or shared bike
|
|
106
91
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
92
|
function MapPopup({
|
|
110
93
|
closePopup = () => {},
|
|
111
94
|
configCompanies,
|
|
@@ -116,16 +99,16 @@ function MapPopup({
|
|
|
116
99
|
setViewedStop
|
|
117
100
|
}) {
|
|
118
101
|
var _entity$networks;
|
|
119
|
-
|
|
120
102
|
const intl = (0, _reactIntl.useIntl)();
|
|
121
103
|
if (!entity) return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
122
104
|
const getNameFunc = getEntityName || (0, _util.makeDefaultGetEntityName)(intl, defaultMessages);
|
|
123
105
|
const name = getNameFunc(entity, configCompanies);
|
|
124
|
-
const stationNetwork = "networks" in entity && (_coreUtils.default.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0
|
|
106
|
+
const stationNetwork = "networks" in entity && (_coreUtils.default.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0 || (_entity$networks = entity.networks) === null || _entity$networks === void 0 ? void 0 : _entity$networks[0]));
|
|
125
107
|
const bikesAvailablePresent = entityIsStation(entity);
|
|
126
108
|
const entityIsStationHub = bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.bikesAvailable) !== undefined && !(entity !== null && entity !== void 0 && entity.isFloatingBike);
|
|
127
|
-
const stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code) || entity.id.split(":")[1] || entity.id;
|
|
109
|
+
const stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code) || entity.id.split(":")[1] || entity.id;
|
|
128
110
|
|
|
111
|
+
// Double quotes make the query invalid, so remove them from the id just in case
|
|
129
112
|
const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, "")}-popup`;
|
|
130
113
|
return /*#__PURE__*/_react.default.createElement(_baseMap.Styled.MapOverlayPopup, null, /*#__PURE__*/_react.default.createElement(_buildingBlocks.FocusTrapWrapper, {
|
|
131
114
|
closePopup: closePopup,
|
|
@@ -149,7 +132,5 @@ function MapPopup({
|
|
|
149
132
|
setLocation: setLocation
|
|
150
133
|
}))));
|
|
151
134
|
}
|
|
152
|
-
|
|
153
|
-
var _default = MapPopup;
|
|
154
|
-
exports.default = _default;
|
|
135
|
+
var _default = exports.default = MapPopup;
|
|
155
136
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx"],"names":["defaultMessages","defaultEnglishMessages","generateLocation","entity","name","lon","entityLon","lat","entityLat","x","y","StationHubDetails","station","value","bikesAvailable","spacesAvailable","StopDetails","id","setViewedStop","stopId","entityIsStation","MapPopup","closePopup","configCompanies","getEntityName","getEntityPrefix","setLocation","intl","getNameFunc","stationNetwork","coreUtils","itinerary","getCompaniesLabelFromNetworks","networks","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","split","encodeURIComponent","replace"],"mappings":";;;;;;;;;;AAAA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAEA;;AAGA;;AACA;;;;;;AAFA;AAIA;AACA;AACA;AACA;AACO,MAAMA,eAA0C,GAAG,mBAAQC,aAAR,CAAnD;;;AAEP,MAAMC,gBAAgB,GAAG,CAACC,MAAD,EAAiBC,IAAjB,KAAkC;AACzD;AACA,QAAM;AAAEC,IAAAA,GAAG,EAAEC,SAAP;AAAkBC,IAAAA,GAAG,EAAEC,SAAvB;AAAkCC,IAAAA,CAAlC;AAAqCC,IAAAA;AAArC,MAA2CP,MAAjD;AAEA,QAAMI,GAAG,GAAGC,SAAS,IAAIE,CAAzB;AACA,QAAML,GAAG,GAAGC,SAAS,IAAIG,CAAzB;AACA,MAAI,CAACF,GAAD,IAAQ,CAACF,GAAb,EAAkB,OAAO,IAAP;AAElB,SAAO;AAAEE,IAAAA,GAAF;AAAOF,IAAAA,GAAP;AAAYD,IAAAA;AAAZ,GAAP;AACD,CATD;;AAWA,MAAMO,iBAAiB,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAuC;AAC/D,sBACE,6BAAC,eAAD,CAAQ,QAAR,qBACE,uDACE,6BAAC,2BAAD;AACE,IAAA,cAAc,EACZZ,eAAe,CAAC,+BAAD,CAFnB;AAIE,IAAA,WAAW,EAAC,8CAJd;AAKE,IAAA,EAAE,EAAC,+BALL;AAME,IAAA,MAAM,EAAE;AA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QACGQ,eAAe,IAAIA,eAAe,CAACtB,MAAD,CADrC,eAEE,6BAAC,2BAAD;AACE,IAAA,cAAc,EAAEH,eAAe,CAAC,2BAAD,CADjC;AAEE,IAAA,WAAW,EAAC,gEAFd;AAGE,IAAA,EAAE,EAAC,2BAHL;AAIE,IAAA,MAAM,EAAE;AAAEI,MAAAA,IAAF;AAAQyB,MAAAA;AAAR;AAJV,IAFF,CADA,EAWCM,kBAAkB,iBAAI,6BAAC,iBAAD;AAAmB,IAAA,OAAO,EAAEhC;AAA5B,IAXvB,EAcCe,aAAa,IAAI,CAACgB,qBAAlB,iBACC,6BAAC,WAAD;AACE,IAAA,EAAE,EAAEf,MADN;AAEE,IAAA,aAAa,EAAE,wBAAY,MAAMD,aAAa,CAACf,MAAD,CAA/B,EAAyC,CAACA,MAAD,CAAzC;AAFjB,IAfF,EAsBCuB,WAAW,iBACV,6BAAC,eAAD,CAAQ,QAAR,qBACE,6BAAC,6BAAD;AACE,IAAA,KAAK,MADP;AAEE,IAAA,QAAQ,EAAExB,gBAAgB,CAACC,MAAD,EAASC,IAAT,CAF5B;AAGE,IAAA,WAAW,EAAEsB;AAHf,IADF,CAvBF,CADF,CADF;AAqCD;;eAEcL,Q","sourcesContent":["import React, { useCallback } from \"react\";\nimport FromToLocationPicker from \"@opentripplanner/from-to-location-picker\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\n// eslint-disable-next-line prettier/prettier\nimport type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from \"@opentripplanner/types\";\n\nimport { FocusTrapWrapper } from \"@opentripplanner/building-blocks\";\nimport { flatten } from \"flat\";\nimport { FormattedMessage, useIntl } from \"react-intl\";\nimport { Styled } from \"@opentripplanner/base-map\";\n\nimport { ViewStopButton } from \"./styled\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\nimport { makeDefaultGetEntityName } from \"./util\";\n\n// HACK: We should flatten the messages loaded above because\n// the YAML loaders behave differently between webpack and our version of jest:\n// - the yaml loader for webpack returns a nested object,\n// - the yaml loader for jest returns messages with flattened ids.\nexport const defaultMessages: { [key: string]: string } = flatten(defaultEnglishMessages);\n\nconst generateLocation = (entity: Entity, name: string) => {\n // @ts-expect-error some of these values may be null, but that's ok\n const { lon: entityLon, lat: entityLat, x, y } = entity\n\n const lat = entityLat || y\n const lon = entityLon || x\n if (!lat || !lon) return null\n\n return { lat, lon, name };\n}\n\nconst StationHubDetails = ({ station }: { station: Station }) => {\n return (\n <Styled.PopupRow>\n <div>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.MapPopup.availableBikes\"]\n }\n description=\"Label text for the number of bikes available\"\n id=\"otpUi.MapPopup.availableBikes\"\n values={{ value: station.bikesAvailable }}\n />\n </div>\n <div>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.MapPopup.availableDocks\"]\n }\n description=\"Label text for the number of docks available\"\n id=\"otpUi.MapPopup.availableDocks\"\n values={{ value: station.spacesAvailable }}\n />\n </div>\n </Styled.PopupRow>\n )\n}\n\nconst StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {\n return (\n <Styled.PopupRow>\n <strong>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.stopId\"]}\n description=\"Displays the stop id\"\n id=\"otpUi.MapPopup.stopId\"\n values={{\n stopId: id\n }}\n />\n </strong>\n <ViewStopButton onClick={setViewedStop}>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.stopViewer\"]}\n description=\"Text for link that opens the stop viewer\"\n id=\"otpUi.MapPopup.stopViewer\"\n />\n </ViewStopButton>\n </Styled.PopupRow>\n )\n}\n\ntype Entity = Stop | Station\ntype Props = {\n closePopup?: (arg?: any) => void\n configCompanies?: ConfiguredCompany[];\n entity: Entity\n getEntityName?: (entity: Entity, configCompanies: Company[],) => string;\n getEntityPrefix?: (entity: Entity) => JSX.Element\n setLocation?: ({ location, locationType }: { location: Location, locationType: string }) => void;\n setViewedStop?: StopEventHandler;\n};\n\nfunction entityIsStation(entity: Entity): entity is Station {\n return \"bikesAvailable\" in entity\n}\n\n/**\n * Renders a map popup for a stop, scooter, or shared bike\n */\nexport function MapPopup({ closePopup = () => {}, configCompanies, entity, getEntityName, getEntityPrefix, setLocation, setViewedStop }: Props): JSX.Element {\n\n const intl = useIntl()\n if (!entity) return <></>\n\n const getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);\n const name = getNameFunc(entity, configCompanies);\n\n const stationNetwork = \"networks\" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks(entity?.networks || [], configCompanies) || entity?.networks?.[0]);\n\n const bikesAvailablePresent = entityIsStation(entity)\n const entityIsStationHub = bikesAvailablePresent && entity?.bikesAvailable !== undefined && !entity?.isFloatingBike;\n const stopId = !bikesAvailablePresent && entity?.code || entity.id.split(\":\")[1] || entity.id\n\n // Double quotes make the query invalid, so remove them from the id just in case\n const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, \"\")}-popup`\n\n return (\n <Styled.MapOverlayPopup>\n <FocusTrapWrapper closePopup={closePopup} id={id}>\n <Styled.PopupTitle>\n {getEntityPrefix && getEntityPrefix(entity)}\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.popupTitle\"]}\n description=\"Text for title of the popup, contains an optional company name\"\n id=\"otpUi.MapPopup.popupTitle\"\n values={{ name, stationNetwork }}\n />\n </Styled.PopupTitle>\n {/* render dock info if it is available */}\n {entityIsStationHub && <StationHubDetails station={entity} />}\n\n {/* render stop viewer link if available */}\n {setViewedStop && !bikesAvailablePresent && (\n <StopDetails\n id={stopId}\n setViewedStop={useCallback(() => setViewedStop(entity), [entity])}\n />\n )}\n\n {/* The \"Set as [from/to]\" ButtonGroup */}\n {setLocation && (\n <Styled.PopupRow>\n <FromToLocationPicker\n label\n location={generateLocation(entity, name)}\n setLocation={setLocation}\n />\n </Styled.PopupRow>\n )}\n </FocusTrapWrapper>\n \n </Styled.MapOverlayPopup>\n );\n}\n\nexport default MapPopup;"],"file":"index.js"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_fromToLocationPicker","_interopRequireDefault","_coreUtils","_buildingBlocks","_flat","_reactIntl","_baseMap","_styled","_enUS","_util","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","defaultMessages","exports","flatten","defaultEnglishMessages","generateLocation","entity","name","lon","entityLon","lat","entityLat","x","y","StationHubDetails","station","createElement","Styled","PopupRow","FormattedMessage","defaultMessage","description","id","values","value","bikesAvailable","spacesAvailable","StopDetails","setViewedStop","stopId","ViewStopButton","onClick","entityIsStation","MapPopup","closePopup","configCompanies","getEntityName","getEntityPrefix","setLocation","_entity$networks","intl","useIntl","Fragment","getNameFunc","makeDefaultGetEntityName","stationNetwork","coreUtils","itinerary","getCompaniesLabelFromNetworks","networks","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","split","encodeURIComponent","replace","MapOverlayPopup","FocusTrapWrapper","PopupTitle","useCallback","label","location","_default"],"sources":["../src/index.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport FromToLocationPicker from \"@opentripplanner/from-to-location-picker\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\n// eslint-disable-next-line prettier/prettier\nimport type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from \"@opentripplanner/types\";\n\nimport { FocusTrapWrapper } from \"@opentripplanner/building-blocks\";\nimport { flatten } from \"flat\";\nimport { FormattedMessage, useIntl } from \"react-intl\";\nimport { Styled } from \"@opentripplanner/base-map\";\n\nimport { ViewStopButton } from \"./styled\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\nimport { makeDefaultGetEntityName } from \"./util\";\n\n// HACK: We should flatten the messages loaded above because\n// the YAML loaders behave differently between webpack and our version of jest:\n// - the yaml loader for webpack returns a nested object,\n// - the yaml loader for jest returns messages with flattened ids.\nexport const defaultMessages: { [key: string]: string } = flatten(defaultEnglishMessages);\n\nconst generateLocation = (entity: Entity, name: string) => {\n // @ts-expect-error some of these values may be null, but that's ok\n const { lon: entityLon, lat: entityLat, x, y } = entity\n\n const lat = entityLat || y\n const lon = entityLon || x\n if (!lat || !lon) return null\n\n return { lat, lon, name };\n}\n\nconst StationHubDetails = ({ station }: { station: Station }) => {\n return (\n <Styled.PopupRow>\n <div>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.MapPopup.availableBikes\"]\n }\n description=\"Label text for the number of bikes available\"\n id=\"otpUi.MapPopup.availableBikes\"\n values={{ value: station.bikesAvailable }}\n />\n </div>\n <div>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.MapPopup.availableDocks\"]\n }\n description=\"Label text for the number of docks available\"\n id=\"otpUi.MapPopup.availableDocks\"\n values={{ value: station.spacesAvailable }}\n />\n </div>\n </Styled.PopupRow>\n )\n}\n\nconst StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {\n return (\n <Styled.PopupRow>\n <strong>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.stopId\"]}\n description=\"Displays the stop id\"\n id=\"otpUi.MapPopup.stopId\"\n values={{\n stopId: id\n }}\n />\n </strong>\n <ViewStopButton onClick={setViewedStop}>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.stopViewer\"]}\n description=\"Text for link that opens the stop viewer\"\n id=\"otpUi.MapPopup.stopViewer\"\n />\n </ViewStopButton>\n </Styled.PopupRow>\n )\n}\n\ntype Entity = Stop | Station\ntype Props = {\n closePopup?: (arg?: any) => void\n configCompanies?: ConfiguredCompany[];\n entity: Entity\n getEntityName?: (entity: Entity, configCompanies: Company[],) => string;\n getEntityPrefix?: (entity: Entity) => JSX.Element\n setLocation?: ({ location, locationType }: { location: Location, locationType: string }) => void;\n setViewedStop?: StopEventHandler;\n};\n\nfunction entityIsStation(entity: Entity): entity is Station {\n return \"bikesAvailable\" in entity\n}\n\n/**\n * Renders a map popup for a stop, scooter, or shared bike\n */\nexport function MapPopup({ closePopup = () => {}, configCompanies, entity, getEntityName, getEntityPrefix, setLocation, setViewedStop }: Props): JSX.Element {\n\n const intl = useIntl()\n if (!entity) return <></>\n\n const getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);\n const name = getNameFunc(entity, configCompanies);\n\n const stationNetwork = \"networks\" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks(entity?.networks || [], configCompanies) || entity?.networks?.[0]);\n\n const bikesAvailablePresent = entityIsStation(entity)\n const entityIsStationHub = bikesAvailablePresent && entity?.bikesAvailable !== undefined && !entity?.isFloatingBike;\n const stopId = !bikesAvailablePresent && entity?.code || entity.id.split(\":\")[1] || entity.id\n\n // Double quotes make the query invalid, so remove them from the id just in case\n const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, \"\")}-popup`\n\n return (\n <Styled.MapOverlayPopup>\n <FocusTrapWrapper closePopup={closePopup} id={id}>\n <Styled.PopupTitle>\n {getEntityPrefix && getEntityPrefix(entity)}\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.popupTitle\"]}\n description=\"Text for title of the popup, contains an optional company name\"\n id=\"otpUi.MapPopup.popupTitle\"\n values={{ name, stationNetwork }}\n />\n </Styled.PopupTitle>\n {/* render dock info if it is available */}\n {entityIsStationHub && <StationHubDetails station={entity} />}\n\n {/* render stop viewer link if available */}\n {setViewedStop && !bikesAvailablePresent && (\n <StopDetails\n id={stopId}\n setViewedStop={useCallback(() => setViewedStop(entity), [entity])}\n />\n )}\n\n {/* The \"Set as [from/to]\" ButtonGroup */}\n {setLocation && (\n <Styled.PopupRow>\n <FromToLocationPicker\n label\n location={generateLocation(entity, name)}\n setLocation={setLocation}\n />\n </Styled.PopupRow>\n )}\n </FocusTrapWrapper>\n \n </Styled.MapOverlayPopup>\n );\n}\n\nexport default MapPopup;"],"mappings":";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,EAAE1D,gBAAgB,CAACC,MAAM,EAAEC,IAAI,CAAE;IACzC+B,WAAW,EAAEA;EAAY,CAC1B,CACc,CAED,CAEI,CAAC;AAE7B;AAAC,IAAA0B,QAAA,GAAA9D,OAAA,CAAAf,OAAA,GAEc8C,QAAQ","ignoreList":[]}
|
package/lib/styled.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ViewStopButton = void 0;
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
9
|
/* eslint-disable-next-line import/prefer-default-export */
|
|
13
|
-
const ViewStopButton = _styledComponents.default.button.withConfig({
|
|
10
|
+
const ViewStopButton = exports.ViewStopButton = _styledComponents.default.button.withConfig({
|
|
14
11
|
displayName: "styled__ViewStopButton",
|
|
15
12
|
componentId: "sc-12v7ov3-0"
|
|
16
13
|
})(["background:none;border-bottom:none;border-left:1px solid #000;border-right:none;border-top:none;color:#008;font-family:inherit;margin-left:5px;padding-top:0;"]);
|
|
17
|
-
|
|
18
|
-
exports.ViewStopButton = ViewStopButton;
|
|
19
14
|
//# sourceMappingURL=styled.js.map
|
package/lib/styled.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"styled.js","names":["_styledComponents","_interopRequireDefault","require","ViewStopButton","exports","styled","button","withConfig","displayName","componentId"],"sources":["../src/styled.ts"],"sourcesContent":["import styled from \"styled-components\";\n\n/* eslint-disable-next-line import/prefer-default-export */\nexport const ViewStopButton = styled.button`\n background: none;\n border-bottom: none;\n border-left: 1px solid #000;\n border-right: none;\n border-top: none;\n color: #008;\n font-family: inherit;\n margin-left: 5px;\n padding-top: 0;\n`;\n"],"mappings":";;;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA;AACO,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAGE,yBAAM,CAACC,MAAM,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,qKAU1C","ignoreList":[]}
|
package/lib/util.js
CHANGED
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.makeDefaultGetEntityName = makeDefaultGetEntityName;
|
|
9
|
-
|
|
10
8
|
var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
|
|
11
|
-
|
|
12
9
|
// eslint-disable-next-line import/prefer-default-export
|
|
13
10
|
function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
|
|
14
11
|
return function defaultGetEntityName(entity, configCompanies) {
|
|
15
12
|
var _entity$networks;
|
|
16
|
-
|
|
17
13
|
// TODO: Stop generating this / passing it to the car string? Is it needed?
|
|
18
14
|
// In English we say "Car: " instead
|
|
19
|
-
const stationNetworks = "networks" in entity && (_coreUtils.default.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0
|
|
20
|
-
let stationName = entity.name || entity.id;
|
|
15
|
+
const stationNetworks = "networks" in entity && (_coreUtils.default.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0 || (_entity$networks = entity.networks) === null || _entity$networks === void 0 ? void 0 : _entity$networks[0]));
|
|
16
|
+
let stationName = entity.name || entity.id;
|
|
17
|
+
// If the station name or id is a giant UUID (with more than 3 "-" characters)
|
|
21
18
|
// best not to show that at all. The company name will still be shown.
|
|
22
19
|
// Also ignore "Default Vehicle Type"
|
|
23
|
-
|
|
24
20
|
if ((stationName.match(/-/g) || []).length > 3 || stationName === "Default vehicle type") {
|
|
25
21
|
stationName = null;
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
if ("isFloatingBike" in entity && entity.isFloatingBike) {
|
|
29
24
|
stationName = intl.formatMessage({
|
|
30
25
|
defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingBike"],
|
|
@@ -52,7 +47,6 @@ function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
|
|
|
52
47
|
name: stationName
|
|
53
48
|
});
|
|
54
49
|
}
|
|
55
|
-
|
|
56
50
|
return stationName;
|
|
57
51
|
};
|
|
58
52
|
}
|
package/lib/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"util.js","names":["_coreUtils","_interopRequireDefault","require","makeDefaultGetEntityName","intl","defaultEnglishMessages","defaultGetEntityName","entity","configCompanies","_entity$networks","stationNetworks","coreUtils","itinerary","getCompaniesLabelFromNetworks","networks","stationName","name","id","match","length","isFloatingBike","formatMessage","defaultMessage","description","isFloatingCar","company","isFloatingVehicle"],"sources":["../src/util.ts"],"sourcesContent":["import { Company, Station, Stop } from \"@opentripplanner/types\";\nimport { IntlShape } from \"react-intl\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\n// eslint-disable-next-line import/prefer-default-export\nexport function makeDefaultGetEntityName(\n intl: IntlShape,\n defaultEnglishMessages: { [key: string]: string }\n) {\n return function defaultGetEntityName(\n entity: Station | Stop,\n configCompanies: Company[]\n ): string | null {\n // TODO: Stop generating this / passing it to the car string? Is it needed?\n // In English we say \"Car: \" instead\n const stationNetworks =\n \"networks\" in entity &&\n (coreUtils.itinerary.getCompaniesLabelFromNetworks(\n entity?.networks || [],\n configCompanies\n ) ||\n entity?.networks?.[0]);\n let stationName: string | null = entity.name || entity.id;\n // If the station name or id is a giant UUID (with more than 3 \"-\" characters)\n // best not to show that at all. The company name will still be shown.\n // Also ignore \"Default Vehicle Type\"\n if (\n (stationName.match(/-/g) || []).length > 3 ||\n stationName === \"Default vehicle type\"\n ) {\n stationName = null;\n }\n\n if (\"isFloatingBike\" in entity && entity.isFloatingBike) {\n stationName = intl.formatMessage(\n {\n defaultMessage: defaultEnglishMessages[\"otpUi.MapPopup.floatingBike\"],\n description: \"Popup title for a free-floating bike\",\n id: \"otpUi.MapPopup.floatingBike\"\n },\n { name: stationName }\n );\n } else if (\"isFloatingCar\" in entity && entity.isFloatingCar) {\n stationName = intl.formatMessage(\n {\n defaultMessage: defaultEnglishMessages[\"otpUi.MapPopup.floatingCar\"],\n description: \"Popup title for a free-floating car\",\n id: \"otpUi.MapPopup.floatingCar\"\n },\n {\n company: stationNetworks,\n name: stationName\n }\n );\n } else if (\"isFloatingVehicle\" in entity && entity.isFloatingVehicle) {\n // assumes that all floating vehicles are E-scooters\n stationName = intl.formatMessage(\n {\n defaultMessage:\n defaultEnglishMessages[\"otpUi.MapPopup.floatingEScooter\"],\n description: \"Popup title for a free-floating e-scooter\",\n id: \"otpUi.MapPopup.floatingEScooter\"\n },\n { name: stationName }\n );\n }\n return stationName;\n };\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA;AACO,SAASC,wBAAwBA,CACtCC,IAAe,EACfC,sBAAiD,EACjD;EACA,OAAO,SAASC,oBAAoBA,CAClCC,MAAsB,EACtBC,eAA0B,EACX;IAAA,IAAAC,gBAAA;IACf;IACA;IACA,MAAMC,eAAe,GACnB,UAAU,IAAIH,MAAM,KACnBI,kBAAS,CAACC,SAAS,CAACC,6BAA6B,CAChD,CAAAN,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEO,QAAQ,KAAI,EAAE,EACtBN,eACF,CAAC,KACCD,MAAM,aAANA,MAAM,gBAAAE,gBAAA,GAANF,MAAM,CAAEO,QAAQ,cAAAL,gBAAA,uBA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2
2
|
"name": "@opentripplanner/map-popup",
|
|
3
|
-
"version": "5.2.0-alpha.
|
|
3
|
+
"version": "5.2.0-alpha.3",
|
|
4
4
|
"description": "A component for displaying map popup contents",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"private": false,
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"
|
|
15
|
-
"@opentripplanner/
|
|
16
|
-
"@opentripplanner/
|
|
17
|
-
"@opentripplanner/
|
|
18
|
-
"
|
|
14
|
+
"flat": "^5.0.2",
|
|
15
|
+
"@opentripplanner/base-map": "5.0.0-alpha.9",
|
|
16
|
+
"@opentripplanner/building-blocks": "2.1.1-alpha.2",
|
|
17
|
+
"@opentripplanner/core-utils": "13.0.0-alpha.3",
|
|
18
|
+
"@opentripplanner/from-to-location-picker": "3.0.2-alpha.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@opentripplanner/types": "
|
|
21
|
+
"@opentripplanner/types": "7.0.0-alpha.17"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "^18.2.0",
|
|
25
|
-
"react-intl": "^
|
|
25
|
+
"react-intl": "^6.8.4",
|
|
26
26
|
"styled-components": "^5.3.0"
|
|
27
27
|
},
|
|
28
28
|
"bugs": {
|
|
@@ -31,4 +31,4 @@
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"tsc": "tsc"
|
|
33
33
|
}
|
|
34
|
-
}
|
|
34
|
+
}
|