@opentripplanner/map-popup 3.1.1-alpha.1 → 3.1.2

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/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback } from "react";
2
- import { Styled as BaseMapStyled } from "@opentripplanner/base-map";
3
- import FromToLocationPicker from "@opentripplanner/from-to-location-picker"; // eslint-disable-next-line prettier/prettier
2
+ import FromToLocationPicker from "@opentripplanner/from-to-location-picker";
3
+ import coreUtils from "@opentripplanner/core-utils"; // eslint-disable-next-line prettier/prettier
4
4
 
5
5
  import { FormattedMessage, useIntl } from "react-intl";
6
6
  import { flatten } from "flat";
@@ -33,7 +33,7 @@ var generateLocation = function generateLocation(entity, name) {
33
33
 
34
34
  var StationHubDetails = function StationHubDetails(_ref) {
35
35
  var station = _ref.station;
36
- return /*#__PURE__*/React.createElement(BaseMapStyled.PopupRow, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, {
36
+ return /*#__PURE__*/React.createElement(S.PopupRow, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, {
37
37
  defaultMessage: defaultMessages["otpUi.MapPopup.availableBikes"],
38
38
  description: "Label text for the number of bikes available",
39
39
  id: "otpUi.MapPopup.availableBikes",
@@ -53,7 +53,7 @@ var StationHubDetails = function StationHubDetails(_ref) {
53
53
  var StopDetails = function StopDetails(_ref2) {
54
54
  var id = _ref2.id,
55
55
  setViewedStop = _ref2.setViewedStop;
56
- return /*#__PURE__*/React.createElement(BaseMapStyled.PopupRow, null, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(FormattedMessage, {
56
+ return /*#__PURE__*/React.createElement(S.PopupRow, null, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(FormattedMessage, {
57
57
  defaultMessage: defaultMessages["otpUi.MapPopup.stopId"],
58
58
  description: "Displays the stop id",
59
59
  id: "otpUi.MapPopup.stopId",
@@ -78,6 +78,8 @@ function entityIsStation(entity) {
78
78
 
79
79
 
80
80
  export function MapPopup(_ref3) {
81
+ var _entity$networks;
82
+
81
83
  var configCompanies = _ref3.configCompanies,
82
84
  entity = _ref3.entity,
83
85
  getEntityName = _ref3.getEntityName,
@@ -87,17 +89,26 @@ export function MapPopup(_ref3) {
87
89
  if (!entity) return /*#__PURE__*/React.createElement(React.Fragment, null);
88
90
  var getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);
89
91
  var name = getNameFunc(entity, configCompanies);
92
+ var stationNetwork = "networks" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0 ? void 0 : (_entity$networks = entity.networks) === null || _entity$networks === void 0 ? void 0 : _entity$networks[0]));
90
93
  var bikesAvailablePresent = entityIsStation(entity);
91
94
  var entityIsStationHub = bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.bikesAvailable) !== undefined && !(entity !== null && entity !== void 0 && entity.isFloatingBike);
92
95
  var stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code) || entity.id.split(":")[1] || entity.id;
93
- return /*#__PURE__*/React.createElement(BaseMapStyled.MapOverlayPopup, null, /*#__PURE__*/React.createElement(BaseMapStyled.PopupTitle, null, name), entityIsStationHub && /*#__PURE__*/React.createElement(StationHubDetails, {
96
+ return /*#__PURE__*/React.createElement(S.MapOverlayPopup, null, /*#__PURE__*/React.createElement(S.PopupTitle, null, /*#__PURE__*/React.createElement(FormattedMessage, {
97
+ defaultMessage: defaultMessages["otpUi.MapPopup.popupTitle"],
98
+ description: "Text for title of the popup, contains an optional company name",
99
+ id: "otpUi.MapPopup.popupTitle",
100
+ values: {
101
+ name: name,
102
+ stationNetwork: stationNetwork
103
+ }
104
+ })), entityIsStationHub && /*#__PURE__*/React.createElement(StationHubDetails, {
94
105
  station: entity
95
106
  }), setViewedStop && !bikesAvailablePresent && /*#__PURE__*/React.createElement(StopDetails, {
96
107
  id: stopId,
97
108
  setViewedStop: useCallback(function () {
98
109
  return setViewedStop(entity);
99
110
  }, [entity])
100
- }), setLocation && /*#__PURE__*/React.createElement(BaseMapStyled.PopupRow, null, /*#__PURE__*/React.createElement(FromToLocationPicker, {
111
+ }), setLocation && /*#__PURE__*/React.createElement(S.PopupRow, null, /*#__PURE__*/React.createElement(FromToLocationPicker, {
101
112
  label: true,
102
113
  location: generateLocation(entity, name),
103
114
  setLocation: setLocation
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.tsx"],"names":["React","useCallback","Styled","BaseMapStyled","FromToLocationPicker","FormattedMessage","useIntl","flatten","S","FocusTrapWrapper","defaultEnglishMessages","makeDefaultGetEntityName","defaultMessages","generateLocation","entity","name","entityLon","lon","entityLat","lat","x","y","StationHubDetails","station","value","bikesAvailable","spacesAvailable","StopDetails","id","setViewedStop","stopId","entityIsStation","MapPopup","configCompanies","getEntityName","setLocation","intl","getNameFunc","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","split"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AAEA,SAASC,MAAM,IAAIC,aAAnB,QAAwC,2BAAxC;AACA,OAAOC,oBAAP,MAAiC,0CAAjC,C,CACA;;AAGA,SAASC,gBAAT,EAA2BC,OAA3B,QAA0C,YAA1C;AACA,SAASC,OAAT,QAAwB,MAAxB;AACA,OAAO,KAAKC,CAAZ,MAAmB,UAAnB;AACA,OAAOC,gBAAP,MAA6B,oBAA7B,C,CAEA;;AACA,OAAOC,sBAAP,MAAmC,mBAAnC;AACA,SAASC,wBAAT,QAAyC,QAAzC,C,CAEA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,eAA0C,GAAGL,OAAO,CAACG,sBAAD,CAA1D;;AAEP,IAAMG,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,MAAD,EAAiBC,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MAAM,CAAE2B,cAAT,CAA5F;AACA,MAAMX,MAAM,GAAG,CAACQ,qBAAD,KAA0BxB,MAA1B,aAA0BA,MAA1B,uBAA0BA,MAAM,CAAE4B,IAAlC,KAA0C5B,MAAM,CAACc,EAAP,CAAUe,KAAV,CAAgB,GAAhB,EAAqB,CAArB,CAA1C,IAAqE7B,MAAM,CAACc,EAA3F;AAEA,sBACE,oBAAC,aAAD,CAAe,eAAf,qBACE,oBAAC,aAAD,CAAe,UAAf,QAA2Bb,IAA3B,CADF,EAGGwB,kBAAkB,iBAAI,oBAAC,iBAAD;AAAmB,IAAA,OAAO,EAAEzB;AAA5B,IAHzB,EAMGe,aAAa,IAAI,CAACS,qBAAlB,iBACC,oBAAC,WAAD;AACE,IAAA,EAAE,EAAER,MADN;AAEE,IAAA,aAAa,EAAE7B,WAAW,CAAC;AAAA,aAAM4B,aAAa,CAACf,MAAD,CAAnB;AAAA,KAAD,EAA8B,CAACA,MAAD,CAA9B;AAF5B,IAPJ,EAcGqB,WAAW,iBACV,oBAAC,aAAD,CAAe,QAAf,qBACE,oBAAC,oBAAD;AACE,IAAA,KAAK,MADP;AAEE,IAAA,QAAQ,EAAEtB,gBAAgB,CAACC,MAAD,EAASC,IAAT,CAF5B;AAGE,IAAA,WAAW,EAAEoB;AAHf,IADF,CAfJ,CADF;AA0BD;AAED,eAAeH,QAAf,C,CAEA;;AACA,SAASxB,CAAC,IAAIN,MAAd,EAAsBO,gBAAtB","sourcesContent":["import React, { useCallback } from \"react\";\n\nimport { Styled as BaseMapStyled } from \"@opentripplanner/base-map\";\nimport FromToLocationPicker from \"@opentripplanner/from-to-location-picker\";\n// eslint-disable-next-line prettier/prettier\nimport type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from \"@opentripplanner/types\";\n\nimport { FormattedMessage, useIntl } from \"react-intl\";\nimport { flatten } from \"flat\";\nimport * as S from \"./styled\";\nimport FocusTrapWrapper from \"./FocusTrapWrapper\";\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 <BaseMapStyled.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 </BaseMapStyled.PopupRow>\n )\n}\n\nconst StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {\n return (\n <BaseMapStyled.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 <S.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 </S.ViewStopButton>\n </BaseMapStyled.PopupRow>\n )\n}\n\ntype Entity = Stop | Station\ntype Props = {\n configCompanies?: ConfiguredCompany[];\n entity: Entity\n getEntityName?: (entity: Entity, configCompanies: Company[],) => string;\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({ configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element {\n const intl = useIntl()\n if (!entity) return <></>\n\n const getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);\n const name = getNameFunc(entity, configCompanies);\n\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 return (\n <BaseMapStyled.MapOverlayPopup>\n <BaseMapStyled.PopupTitle>{name}</BaseMapStyled.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 <BaseMapStyled.PopupRow>\n <FromToLocationPicker\n label\n location={generateLocation(entity, name)}\n setLocation={setLocation}\n />\n </BaseMapStyled.PopupRow>\n )}\n </BaseMapStyled.MapOverlayPopup>\n );\n}\n\nexport default MapPopup;\n\n// Rename styled components for export.\nexport { S as Styled, FocusTrapWrapper };"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.tsx"],"names":["React","useCallback","FromToLocationPicker","coreUtils","FormattedMessage","useIntl","flatten","S","FocusTrapWrapper","defaultEnglishMessages","makeDefaultGetEntityName","defaultMessages","generateLocation","entity","name","entityLon","lon","entityLat","lat","x","y","StationHubDetails","station","value","bikesAvailable","spacesAvailable","StopDetails","id","setViewedStop","stopId","entityIsStation","MapPopup","configCompanies","getEntityName","setLocation","intl","getNameFunc","stationNetwork","itinerary","getCompaniesLabelFromNetworks","networks","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","split","Styled"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AACA,OAAOC,oBAAP,MAAiC,0CAAjC;AACA,OAAOC,SAAP,MAAsB,6BAAtB,C,CAEA;;AAGA,SAASC,gBAAT,EAA2BC,OAA3B,QAA0C,YAA1C;AACA,SAASC,OAAT,QAAwB,MAAxB;AACA,OAAO,KAAKC,CAAZ,MAAmB,UAAnB;AACA,OAAOC,gBAAP,MAA6B,oBAA7B,C,CAEA;;AACA,OAAOC,sBAAP,MAAmC,mBAAnC;AACA,SAASC,wBAAT,QAAyC,QAAzC,C,CAEA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,eAA0C,GAAGL,OAAO,CAACG,sBAAD,CAA1D;;AAEP,IAAMG,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,MAAD,EAAiBC,IAAjB,EAAkC;AACzD;AACA,MAAaC,SAAb,GAAiDF,MAAjD,CAAQG,GAAR;AAAA,MAA6BC,SAA7B,GAAiDJ,MAAjD,CAAwBK,GAAxB;AAAA,MAAwCC,CAAxC,GAAiDN,MAAjD,CAAwCM,CAAxC;AAAA,MAA2CC,CAA3C,GAAiDP,MAAjD,CAA2CO,CAA3C;AAEA,MAAMF,GAAG,GAAGD,SAAS,IAAIG,CAAzB;AACA,MAAMJ,GAAG,GAAGD,SAAS,IAAII,CAAzB;AACA,MAAI,CAACD,GAAD,IAAQ,CAACF,GAAb,EAAkB,OAAO,IAAP;AAElB,SAAO;AAAEE,IAAAA,GAAG,EAAHA,GAAF;AAAOF,IAAAA,GAAG,EAAHA,GAAP;AAAYF,IAAAA,IAAI,EAAJA;AAAZ,GAAP;AACD,CATD;;AAWA,IAAMO,iBAAiB,GAAG,SAApBA,iBAAoB,OAAuC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AD,CAAG,eAAH,qBACE,oBAAC,CAAD,CAAG,UAAH,qBACE,oBAAC,gBAAD;AACE,IAAA,cAAc,EAAEhB,eAAe,CAAC,2BAAD,CADjC;AAEE,IAAA,WAAW,EAAC,gEAFd;AAGE,IAAA,EAAE,EAAC,2BAHL;AAIE,IAAA,MAAM,EAAE;AAAEG,MAAAA,IAAI,EAAJA,IAAF;AAAQuB,MAAAA,cAAc,EAAdA;AAAR;AAJV,IADF,CADF,EAUGK,kBAAkB,iBAAI,oBAAC,iBAAD;AAAmB,IAAA,OAAO,EAAE7B;AAA5B,IAVzB,EAaGe,aAAa,IAAI,CAACa,qBAAlB,iBACC,oBAAC,WAAD;AACE,IAAA,EAAE,EAAEZ,MADN;AAEE,IAAA,aAAa,EAAE5B,WAAW,CAAC;AAAA,aAAM2B,aAAa,CAACf,MAAD,CAAnB;AAAA,KAAD,EAA8B,CAACA,MAAD,CAA9B;AAF5B,IAdJ,EAqBGqB,WAAW,iBACV,oBAAC,CAAD,CAAG,QAAH,qBACE,oBAAC,oBAAD;AACE,IAAA,KAAK,MADP;AAEE,IAAA,QAAQ,EAAEtB,gBAAgB,CAACC,MAAD,EAASC,IAAT,CAF5B;AAGE,IAAA,WAAW,EAAEoB;AAHf,IADF,CAtBJ,CADF;AAiCD;AAED,eAAeH,QAAf,C,CAEA;;AACA,SAASxB,CAAC,IAAIwC,MAAd,EAAsBvC,gBAAtB","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 { FormattedMessage, useIntl } from \"react-intl\";\nimport { flatten } from \"flat\";\nimport * as S from \"./styled\";\nimport FocusTrapWrapper from \"./FocusTrapWrapper\";\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 <S.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 </S.PopupRow>\n )\n}\n\nconst StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {\n return (\n <S.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 <S.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 </S.ViewStopButton>\n </S.PopupRow>\n )\n}\n\ntype Entity = Stop | Station\ntype Props = {\n configCompanies?: ConfiguredCompany[];\n entity: Entity\n getEntityName?: (entity: Entity, configCompanies: Company[],) => string;\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({ configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element {\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 return (\n <S.MapOverlayPopup>\n <S.PopupTitle>\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 </S.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 <S.PopupRow>\n <FromToLocationPicker\n label\n location={generateLocation(entity, name)}\n setLocation={setLocation}\n />\n </S.PopupRow>\n )}\n </S.MapOverlayPopup>\n );\n}\n\nexport default MapPopup;\n\n// Rename styled components for export.\nexport { S as Styled, FocusTrapWrapper };"],"file":"index.js"}
package/esm/styled.js CHANGED
@@ -1,8 +1,29 @@
1
1
  import styled from "styled-components";
2
+ import { Popup as MapGlPopup } from "react-map-gl";
2
3
  /* eslint-disable-next-line import/prefer-default-export */
3
4
 
4
5
  export var ViewStopButton = styled.button.withConfig({
5
6
  displayName: "styled__ViewStopButton",
6
7
  componentId: "sc-12v7ov3-0"
7
8
  })(["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;"]);
9
+ /**
10
+ * Adds a box shadow and tweaks border radius to make popups easier to read.
11
+ */
12
+
13
+ export var Popup = styled(MapGlPopup).withConfig({
14
+ displayName: "styled__Popup",
15
+ componentId: "sc-12v7ov3-1"
16
+ })(["& > .maplibregl-popup-content,& > .mapboxgl-popup-content{border-radius:10px;box-shadow:0 3px 14px 4px rgb(0 0 0 / 20%);}"]);
17
+ export var MapOverlayPopup = styled.div.withConfig({
18
+ displayName: "styled__MapOverlayPopup",
19
+ componentId: "sc-12v7ov3-2"
20
+ })(["font-size:12px;line-height:1.5;min-width:250px;"]);
21
+ export var PopupRow = styled.p.withConfig({
22
+ displayName: "styled__PopupRow",
23
+ componentId: "sc-12v7ov3-3"
24
+ })(["margin-top:6px;"]);
25
+ export var PopupTitle = styled.header.withConfig({
26
+ displayName: "styled__PopupTitle",
27
+ componentId: "sc-12v7ov3-4"
28
+ })(["font-size:18px;font-weight:500;margin-bottom:6px;"]);
8
29
  //# sourceMappingURL=styled.js.map
package/esm/styled.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/styled.ts"],"names":["styled","ViewStopButton","button"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,mBAAnB;AAEA;;AACA,OAAO,IAAMC,cAAc,GAAGD,MAAM,CAACE,MAAV;AAAA;AAAA;AAAA,qKAApB","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"],"file":"styled.js"}
1
+ {"version":3,"sources":["../src/styled.ts"],"names":["styled","Popup","MapGlPopup","ViewStopButton","button","MapOverlayPopup","div","PopupRow","p","PopupTitle","header"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,mBAAnB;AAEA,SAASC,KAAK,IAAIC,UAAlB,QAAoC,cAApC;AAEA;;AACA,OAAO,IAAMC,cAAc,GAAGH,MAAM,CAACI,MAAV;AAAA;AAAA;AAAA,qKAApB;AAYP;AACA;AACA;;AACA,OAAO,IAAMH,KAAK,GAAGD,MAAM,CAACE,UAAD,CAAT;AAAA;AAAA;AAAA,iIAAX;AAQP,OAAO,IAAMG,eAAe,GAAGL,MAAM,CAACM,GAAV;AAAA;AAAA;AAAA,uDAArB;AAMP,OAAO,IAAMC,QAAQ,GAAGP,MAAM,CAACQ,CAAV;AAAA;AAAA;AAAA,uBAAd;AAIP,OAAO,IAAMC,UAAU,GAAGT,MAAM,CAACU,MAAV;AAAA;AAAA;AAAA,yDAAhB","sourcesContent":["import styled from \"styled-components\";\n\nimport { Popup as MapGlPopup } from \"react-map-gl\";\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\n/**\n * Adds a box shadow and tweaks border radius to make popups easier to read.\n */\nexport const Popup = styled(MapGlPopup)`\n & > .maplibregl-popup-content,\n & > .mapboxgl-popup-content {\n border-radius: 10px;\n box-shadow: 0 3px 14px 4px rgb(0 0 0 / 20%);\n }\n`;\n\nexport const MapOverlayPopup = styled.div`\n font-size: 12px;\n line-height: 1.5;\n min-width: 250px;\n`;\n\nexport const PopupRow = styled.p`\n margin-top: 6px;\n`;\n\nexport const PopupTitle = styled.header`\n font-size: 18px;\n font-weight: 500;\n margin-bottom: 6px;\n`;\n"],"file":"styled.js"}
package/esm/util.js CHANGED
@@ -4,6 +4,8 @@ export function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
4
4
  return function defaultGetEntityName(entity, configCompanies) {
5
5
  var _entity$networks;
6
6
 
7
+ // TODO: Stop generating this / passing it to the car string? Is it needed?
8
+ // In English we say "Car: " instead
7
9
  var stationNetworks = "networks" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0 ? void 0 : (_entity$networks = entity.networks) === null || _entity$networks === void 0 ? void 0 : _entity$networks[0]));
8
10
  var stationName = entity.name || entity.id; // If the station name or id is a giant UUID (with more than 3 "-" characters)
9
11
  // best not to show that at all. The company name will still be shown.
@@ -19,7 +21,7 @@ export function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
19
21
  description: "Popup title for a free-floating bike",
20
22
  id: "otpUi.MapPopup.floatingBike"
21
23
  }, {
22
- name: stationName || stationNetworks
24
+ name: stationName
23
25
  });
24
26
  } else if ("isFloatingCar" in entity && entity.isFloatingCar) {
25
27
  stationName = intl.formatMessage({
@@ -37,7 +39,7 @@ export function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
37
39
  description: "Popup title for a free-floating e-scooter",
38
40
  id: "otpUi.MapPopup.floatingEScooter"
39
41
  }, {
40
- name: stationName || stationNetworks
42
+ name: stationName
41
43
  });
42
44
  }
43
45
 
package/esm/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/util.ts"],"names":["coreUtils","makeDefaultGetEntityName","intl","defaultEnglishMessages","defaultGetEntityName","entity","configCompanies","stationNetworks","itinerary","getCompaniesLabelFromNetworks","networks","stationName","name","id","match","length","isFloatingBike","formatMessage","defaultMessage","description","isFloatingCar","company","isFloatingVehicle"],"mappings":"AAEA,OAAOA,SAAP,MAAsB,6BAAtB,C,CAEA;;AACA,OAAO,SAASC,wBAAT,CACLC,IADK,EAELC,sBAFK,EAGL;AACA,SAAO,SAASC,oBAAT,CACLC,MADK,EAELC,eAFK,EAGU;AAAA;;AACf,QAAMC,eAAe,GAC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,MAAAA,WAAW,GAAGT,IAAI,CAACe,aAAL,CACZ;AACEC,QAAAA,cAAc,EACZf,sBAAsB,CAAC,iCAAD,CAF1B;AAGEgB,QAAAA,WAAW,EAAE,2CAHf;AAIEN,QAAAA,EAAE,EAAE;AAJN,OADY,EAOZ;AAAED,QAAAA,IAAI,EAAED,WAAW,IAAIJ;AAAvB,OAPY,CAAd;AASD;;AACD,WAAOI,WAAP;AACD,GAxDD;AAyDD","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 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 || stationNetworks }\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 || stationNetworks }\n );\n }\n return stationName;\n };\n}\n"],"file":"util.js"}
1
+ {"version":3,"sources":["../src/util.ts"],"names":["coreUtils","makeDefaultGetEntityName","intl","defaultEnglishMessages","defaultGetEntityName","entity","configCompanies","stationNetworks","itinerary","getCompaniesLabelFromNetworks","networks","stationName","name","id","match","length","isFloatingBike","formatMessage","defaultMessage","description","isFloatingCar","company","isFloatingVehicle"],"mappings":"AAEA,OAAOA,SAAP,MAAsB,6BAAtB,C,CAEA;;AACA,OAAO,SAASC,wBAAT,CACLC,IADK,EAELC,sBAFK,EAGL;AACA,SAAO,SAASC,oBAAT,CACLC,MADK,EAELC,eAFK,EAGU;AAAA;;AACf;AACA;AACA,QAAMC,eAAe,GACnB,cAAcF,MAAd,KACCL,SAAS,CAACQ,SAAV,CAAoBC,6BAApB,CACC,CAAAJ,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEK,QAAR,KAAoB,EADrB,EAECJ,eAFD,MAICD,MAJD,aAICA,MAJD,2CAICA,MAAM,CAAEK,QAJT,qDAIC,iBAAmB,CAAnB,CAJD,CADD,CADF;AAOA,QAAIC,WAA0B,GAAGN,MAAM,CAACO,IAAP,IAAeP,MAAM,CAACQ,EAAvD,CAVe,CAWf;AACA;AACA;;AACA,QACE,CAACF,WAAW,CAACG,KAAZ,CAAkB,IAAlB,KAA2B,EAA5B,EAAgCC,MAAhC,GAAyC,CAAzC,IACAJ,WAAW,KAAK,sBAFlB,EAGE;AACAA,MAAAA,WAAW,GAAG,IAAd;AACD;;AAED,QAAI,oBAAoBN,MAApB,IAA8BA,MAAM,CAACW,cAAzC,EAAyD;AACvDL,MAAAA,WAAW,GAAGT,IAAI,CAACe,aAAL,CACZ;AACEC,QAAAA,cAAc,EAAEf,sBAAsB,CAAC,6BAAD,CADxC;AAEEgB,QAAAA,WAAW,EAAE,sCAFf;AAGEN,QAAAA,EAAE,EAAE;AAHN,OADY,EAMZ;AAAED,QAAAA,IAAI,EAAED;AAAR,OANY,CAAd;AAQD,KATD,MASO,IAAI,mBAAmBN,MAAnB,IAA6BA,MAAM,CAACe,aAAxC,EAAuD;AAC5DT,MAAAA,WAAW,GAAGT,IAAI,CAACe,aAAL,CACZ;AACEC,QAAAA,cAAc,EAAEf,sBAAsB,CAAC,4BAAD,CADxC;AAEEgB,QAAAA,WAAW,EAAE,qCAFf;AAGEN,QAAAA,EAAE,EAAE;AAHN,OADY,EAMZ;AACEQ,QAAAA,OAAO,EAAEd,eADX;AAEEK,QAAAA,IAAI,EAAED;AAFR,OANY,CAAd;AAWD,KAZM,MAYA,IAAI,uBAAuBN,MAAvB,IAAiCA,MAAM,CAACiB,iBAA5C,EAA+D;AACpE;AACAX,MAAAA,WAAW,GAAGT,IAAI,CAACe,aAAL,CACZ;AACEC,QAAAA,cAAc,EACZf,sBAAsB,CAAC,iCAAD,CAF1B;AAGEgB,QAAAA,WAAW,EAAE,2CAHf;AAIEN,QAAAA,EAAE,EAAE;AAJN,OADY,EAOZ;AAAED,QAAAA,IAAI,EAAED;AAAR,OAPY,CAAd;AASD;;AACD,WAAOA,WAAP;AACD,GA1DD;AA2DD","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"],"file":"util.js"}
package/i18n/en-US.yml CHANGED
@@ -3,7 +3,8 @@ otpUi:
3
3
  availableBikes: "Available bikes: {value}"
4
4
  availableDocks: "Available docks: {value}"
5
5
  floatingBike: "Free-floating bike: {name}"
6
- floatingCar: "{company} {name}"
6
+ floatingCar: "Car: {name}"
7
7
  floatingEScooter: "E-scooter: {name}"
8
+ popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
8
9
  stopId: "Stop ID: {stopId}"
9
10
  stopViewer: Stop Viewer
package/i18n/es.yml CHANGED
@@ -3,7 +3,8 @@ otpUi:
3
3
  availableBikes: "Bicicletas disponibles: {value}"
4
4
  availableDocks: "Estaciones de carga disponibles: {value}"
5
5
  floatingBike: "Bicicleta flotante: {name}"
6
- floatingCar: "{company} {name}"
6
+ floatingCar: "Carro: {name}"
7
7
  floatingEScooter: Scooter eléctrico {name}
8
+ popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
8
9
  stopId: Parada n°{stopId}
9
10
  stopViewer: Visor de paradas
package/i18n/fr.yml CHANGED
@@ -3,7 +3,8 @@ otpUi:
3
3
  availableBikes: "Vélos disponibles : {value}"
4
4
  availableDocks: "Bornes disponibles : {value}"
5
5
  floatingBike: "Vélo flottant : {name}"
6
- floatingCar: "{company} {name}"
6
+ floatingCar: "Voiture : {name}"
7
7
  floatingEScooter: Trottinette {name}
8
+ popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
8
9
  stopId: Arrêt n°{stopId}
9
10
  stopViewer: Info arrêt
package/i18n/ko.yml CHANGED
@@ -3,7 +3,8 @@ otpUi:
3
3
  availableBikes: "사용 가능한 자전거: {value}"
4
4
  availableDocks: "사용 가능한 도크: {value}"
5
5
  floatingBike: "프리-플로팅 자전거: {name}"
6
- floatingCar: "{company} {name}"
6
+ floatingCar: "자동차: {name}"
7
7
  floatingEScooter: "{name} 전동스쿠터"
8
+ popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
8
9
  stopId: "정류장 ID: {stopId}"
9
10
  stopViewer: 정류장 뷰어
package/i18n/nb_NO.yml CHANGED
@@ -1,9 +1,10 @@
1
1
  otpUi:
2
2
  MapPopup:
3
3
  availableBikes: "Tilgjengelige sykler: {value}"
4
+ availableDocks: "Tilgjengelige stasjoner: {value}"
5
+ floatingBike: "Stasjonsløs sykkel: {name}"
4
6
  floatingCar: "{company} {name}"
7
+ floatingEScooter: "E-scooter: {name}"
8
+ popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
5
9
  stopId: "Stopp-ID: {stopId}"
6
10
  stopViewer: Stopp-viser
7
- availableDocks: "Tilgjengelige stasjoner: {value}"
8
- floatingEScooter: "E-scooter: {name}"
9
- floatingBike: "Stasjonsløs sykkel: {name}"
package/i18n/ru.yml CHANGED
@@ -3,7 +3,8 @@ otpUi:
3
3
  availableBikes: "Доступные велосипеды: {value}"
4
4
  availableDocks: "Доступные станции: {value}"
5
5
  floatingBike: "Арендный велосипед не на станции: {name}"
6
- floatingCar: "{company} {name}"
6
+ floatingCar: "Авто: {name}"
7
7
  floatingEScooter: "Электросамокат: {name}"
8
+ popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
8
9
  stopId: "Идентификатор остановки: {stopId}"
9
10
  stopViewer: Средство просмотра остановок
package/i18n/tl.yml CHANGED
@@ -3,7 +3,8 @@ otpUi:
3
3
  availableBikes: "Mga available na bisikleta: {value}"
4
4
  availableDocks: "Mga available na dock: {value}"
5
5
  floatingBike: "Free-floating na bisikleta: {name}"
6
- floatingCar: "{company} {name}"
6
+ floatingCar: "Sasakyan: {name}"
7
7
  floatingEScooter: "E-scooter: {name}"
8
+ popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
8
9
  stopId: "ID ng Hintuan: {stopId}"
9
10
  stopViewer: Ihinto ang Viewer
package/i18n/tr.yml CHANGED
@@ -5,5 +5,6 @@ otpUi:
5
5
  floatingBike: "Serbest gezen bisiklet: {name}"
6
6
  floatingCar: "{company} {name}"
7
7
  floatingEScooter: "E-skuter: {name}"
8
+ popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
8
9
  stopId: "Durak ID: {stopId}"
9
10
  stopViewer: Durak Gösterici
package/i18n/vi.yml CHANGED
@@ -3,7 +3,8 @@ otpUi:
3
3
  availableBikes: "Xe đạp có sẵn: {value}"
4
4
  availableDocks: "Chỗ dựng xe đạp có sẵn: {value}"
5
5
  floatingBike: "Xe đạp để tự do: {name}"
6
- floatingCar: "{company} {name}"
6
+ floatingCar: "Xe hơi: {name}"
7
7
  floatingEScooter: Xe tay ga điện {name}
8
+ popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
8
9
  stopId: Điểm dừng số {stopId}
9
10
  stopViewer: Xem điểm dừng
package/i18n/zh_Hans.yml CHANGED
@@ -3,7 +3,8 @@ otpUi:
3
3
  availableBikes: "可用的自行车: {value}"
4
4
  availableDocks: "可用的充电座: {value}"
5
5
  floatingBike: "自由浮动的自行车: {name}"
6
- floatingCar: "{company} {name}"
6
+ floatingCar: "汽车: {name}"
7
7
  floatingEScooter: "{name} 电动滑板车"
8
+ popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
8
9
  stopId: "车站 ID: {stopId}"
9
10
  stopViewer: 车站查看器
@@ -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;AAIpH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAUlD,eAAO,MAAM,eAAe,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAoC,CAAC;AAgE1F,aAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAA;AAC5B,aAAK,KAAK,GAAG;IACX,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,WAAW,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,YAAY,EA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W,EAAE,aAAa,EAAE,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CA8CnH;AAED,eAAe,QAAQ,CAAC;AAGxB,OAAO,EAAE,CAAC,IAAI,MAAM,EAAE,gBAAgB,EAAE,CAAC"}
package/lib/index.js CHANGED
@@ -16,10 +16,10 @@ exports.Styled = exports.default = exports.defaultMessages = void 0;
16
16
 
17
17
  var _react = _interopRequireWildcard(require("react"));
18
18
 
19
- var _baseMap = require("@opentripplanner/base-map");
20
-
21
19
  var _fromToLocationPicker = _interopRequireDefault(require("@opentripplanner/from-to-location-picker"));
22
20
 
21
+ var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
22
+
23
23
  var _reactIntl = require("react-intl");
24
24
 
25
25
  var _flat = require("flat");
@@ -67,7 +67,7 @@ const generateLocation = (entity, name) => {
67
67
  const StationHubDetails = ({
68
68
  station
69
69
  }) => {
70
- return /*#__PURE__*/_react.default.createElement(_baseMap.Styled.PopupRow, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
70
+ return /*#__PURE__*/_react.default.createElement(S.PopupRow, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
71
71
  defaultMessage: defaultMessages["otpUi.MapPopup.availableBikes"],
72
72
  description: "Label text for the number of bikes available",
73
73
  id: "otpUi.MapPopup.availableBikes",
@@ -88,7 +88,7 @@ const StopDetails = ({
88
88
  id,
89
89
  setViewedStop
90
90
  }) => {
91
- return /*#__PURE__*/_react.default.createElement(_baseMap.Styled.PopupRow, null, /*#__PURE__*/_react.default.createElement("strong", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
91
+ return /*#__PURE__*/_react.default.createElement(S.PopupRow, null, /*#__PURE__*/_react.default.createElement("strong", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
92
92
  defaultMessage: defaultMessages["otpUi.MapPopup.stopId"],
93
93
  description: "Displays the stop id",
94
94
  id: "otpUi.MapPopup.stopId",
@@ -119,19 +119,30 @@ function MapPopup({
119
119
  setLocation,
120
120
  setViewedStop
121
121
  }) {
122
+ var _entity$networks;
123
+
122
124
  const intl = (0, _reactIntl.useIntl)();
123
125
  if (!entity) return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
124
126
  const getNameFunc = getEntityName || (0, _util.makeDefaultGetEntityName)(intl, defaultMessages);
125
127
  const name = getNameFunc(entity, configCompanies);
128
+ const stationNetwork = "networks" in entity && (_coreUtils.default.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0 ? void 0 : (_entity$networks = entity.networks) === null || _entity$networks === void 0 ? void 0 : _entity$networks[0]));
126
129
  const bikesAvailablePresent = entityIsStation(entity);
127
130
  const entityIsStationHub = bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.bikesAvailable) !== undefined && !(entity !== null && entity !== void 0 && entity.isFloatingBike);
128
131
  const stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code) || entity.id.split(":")[1] || entity.id;
129
- return /*#__PURE__*/_react.default.createElement(_baseMap.Styled.MapOverlayPopup, null, /*#__PURE__*/_react.default.createElement(_baseMap.Styled.PopupTitle, null, name), entityIsStationHub && /*#__PURE__*/_react.default.createElement(StationHubDetails, {
132
+ return /*#__PURE__*/_react.default.createElement(S.MapOverlayPopup, null, /*#__PURE__*/_react.default.createElement(S.PopupTitle, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
133
+ defaultMessage: defaultMessages["otpUi.MapPopup.popupTitle"],
134
+ description: "Text for title of the popup, contains an optional company name",
135
+ id: "otpUi.MapPopup.popupTitle",
136
+ values: {
137
+ name,
138
+ stationNetwork
139
+ }
140
+ })), entityIsStationHub && /*#__PURE__*/_react.default.createElement(StationHubDetails, {
130
141
  station: entity
131
142
  }), setViewedStop && !bikesAvailablePresent && /*#__PURE__*/_react.default.createElement(StopDetails, {
132
143
  id: stopId,
133
144
  setViewedStop: (0, _react.useCallback)(() => setViewedStop(entity), [entity])
134
- }), setLocation && /*#__PURE__*/_react.default.createElement(_baseMap.Styled.PopupRow, null, /*#__PURE__*/_react.default.createElement(_fromToLocationPicker.default, {
145
+ }), setLocation && /*#__PURE__*/_react.default.createElement(S.PopupRow, null, /*#__PURE__*/_react.default.createElement(_fromToLocationPicker.default, {
135
146
  label: true,
136
147
  location: generateLocation(entity, name),
137
148
  setLocation: setLocation
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","configCompanies","getEntityName","setLocation","intl","getNameFunc","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","split"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AAIA;;AACA;;AACA;;;;AACA;;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;;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,6BAAC,6BAAD;AACE,IAAA,KAAK,MADP;AAEE,IAAA,QAAQ,EAAEtB,gBAAgB,CAACC,MAAD,EAASC,IAAT,CAF5B;AAGE,IAAA,WAAW,EAAEoB;AAHf,IADF,CAfJ,CADF;AA0BD;;eAEcH,Q,EAEf","sourcesContent":["import React, { useCallback } from \"react\";\n\nimport { Styled as BaseMapStyled } from \"@opentripplanner/base-map\";\nimport FromToLocationPicker from \"@opentripplanner/from-to-location-picker\";\n// eslint-disable-next-line prettier/prettier\nimport type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from \"@opentripplanner/types\";\n\nimport { FormattedMessage, useIntl } from \"react-intl\";\nimport { flatten } from \"flat\";\nimport * as S from \"./styled\";\nimport FocusTrapWrapper from \"./FocusTrapWrapper\";\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 <BaseMapStyled.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 </BaseMapStyled.PopupRow>\n )\n}\n\nconst StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {\n return (\n <BaseMapStyled.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 <S.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 </S.ViewStopButton>\n </BaseMapStyled.PopupRow>\n )\n}\n\ntype Entity = Stop | Station\ntype Props = {\n configCompanies?: ConfiguredCompany[];\n entity: Entity\n getEntityName?: (entity: Entity, configCompanies: Company[],) => string;\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({ configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element {\n const intl = useIntl()\n if (!entity) return <></>\n\n const getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);\n const name = getNameFunc(entity, configCompanies);\n\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 return (\n <BaseMapStyled.MapOverlayPopup>\n <BaseMapStyled.PopupTitle>{name}</BaseMapStyled.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 <BaseMapStyled.PopupRow>\n <FromToLocationPicker\n label\n location={generateLocation(entity, name)}\n setLocation={setLocation}\n />\n </BaseMapStyled.PopupRow>\n )}\n </BaseMapStyled.MapOverlayPopup>\n );\n}\n\nexport default MapPopup;\n\n// Rename styled components for export.\nexport { S as Styled, FocusTrapWrapper };"],"file":"index.js"}
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","configCompanies","getEntityName","setLocation","intl","getNameFunc","stationNetwork","coreUtils","itinerary","getCompaniesLabelFromNetworks","networks","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","split"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAKA;;AACA;;AACA;;;;AACA;;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,C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CADjC;AAEE,IAAA,WAAW,EAAC,gEAFd;AAGE,IAAA,EAAE,EAAC,2BAHL;AAIE,IAAA,MAAM,EAAE;AAAEI,MAAAA,IAAF;AAAQuB,MAAAA;AAAR;AAJV,IADF,CADF,EAUGM,kBAAkB,iBAAI,6BAAC,iBAAD;AAAmB,IAAA,OAAO,EAAE9B;AAA5B,IAVzB,EAaGe,aAAa,IAAI,CAACc,qBAAlB,iBACC,6BAAC,WAAD;AACE,IAAA,EAAE,EAAEb,MADN;AAEE,IAAA,aAAa,EAAE,wBAAY,MAAMD,aAAa,CAACf,MAAD,CAA/B,EAAyC,CAACA,MAAD,CAAzC;AAFjB,IAdJ,EAqBGqB,WAAW,iBACV,6BAAC,CAAD,CAAG,QAAH,qBACE,6BAAC,6BAAD;AACE,IAAA,KAAK,MADP;AAEE,IAAA,QAAQ,EAAEtB,gBAAgB,CAACC,MAAD,EAASC,IAAT,CAF5B;AAGE,IAAA,WAAW,EAAEoB;AAHf,IADF,CAtBJ,CADF;AAiCD;;eAEcH,Q,EAEf","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 { FormattedMessage, useIntl } from \"react-intl\";\nimport { flatten } from \"flat\";\nimport * as S from \"./styled\";\nimport FocusTrapWrapper from \"./FocusTrapWrapper\";\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 <S.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 </S.PopupRow>\n )\n}\n\nconst StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {\n return (\n <S.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 <S.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 </S.ViewStopButton>\n </S.PopupRow>\n )\n}\n\ntype Entity = Stop | Station\ntype Props = {\n configCompanies?: ConfiguredCompany[];\n entity: Entity\n getEntityName?: (entity: Entity, configCompanies: Company[],) => string;\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({ configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element {\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 return (\n <S.MapOverlayPopup>\n <S.PopupTitle>\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 </S.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 <S.PopupRow>\n <FromToLocationPicker\n label\n location={generateLocation(entity, name)}\n setLocation={setLocation}\n />\n </S.PopupRow>\n )}\n </S.MapOverlayPopup>\n );\n}\n\nexport default MapPopup;\n\n// Rename styled components for export.\nexport { S as Styled, FocusTrapWrapper };"],"file":"index.js"}
package/lib/styled.d.ts CHANGED
@@ -1,2 +1,10 @@
1
+ /// <reference types="react" />
1
2
  export declare const ViewStopButton: import("styled-components").StyledComponent<"button", any, {}, never>;
3
+ /**
4
+ * Adds a box shadow and tweaks border radius to make popups easier to read.
5
+ */
6
+ export declare const Popup: import("styled-components").StyledComponent<import("react").MemoExoticComponent<(props: import("react-map-gl").PopupProps) => any>, any, {}, never>;
7
+ export declare const MapOverlayPopup: import("styled-components").StyledComponent<"div", any, {}, never>;
8
+ export declare const PopupRow: import("styled-components").StyledComponent<"p", any, {}, never>;
9
+ export declare const PopupTitle: import("styled-components").StyledComponent<"header", any, {}, never>;
2
10
  //# sourceMappingURL=styled.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,uEAU1B,CAAC"}
1
+ {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":";AAKA,eAAO,MAAM,cAAc,uEAU1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,qJAMjB,CAAC;AAEF,eAAO,MAAM,eAAe,oEAI3B,CAAC;AAEF,eAAO,MAAM,QAAQ,kEAEpB,CAAC;AAEF,eAAO,MAAM,UAAU,uEAItB,CAAC"}
package/lib/styled.js CHANGED
@@ -5,15 +5,47 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.ViewStopButton = void 0;
8
+ exports.PopupTitle = exports.PopupRow = exports.MapOverlayPopup = exports.Popup = exports.ViewStopButton = void 0;
9
9
 
10
10
  var _styledComponents = _interopRequireDefault(require("styled-components"));
11
11
 
12
+ var _reactMapGl = require("react-map-gl");
13
+
12
14
  /* eslint-disable-next-line import/prefer-default-export */
13
15
  const ViewStopButton = _styledComponents.default.button.withConfig({
14
16
  displayName: "styled__ViewStopButton",
15
17
  componentId: "sc-12v7ov3-0"
16
18
  })(["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;"]);
19
+ /**
20
+ * Adds a box shadow and tweaks border radius to make popups easier to read.
21
+ */
22
+
17
23
 
18
24
  exports.ViewStopButton = ViewStopButton;
25
+ const Popup = (0, _styledComponents.default)(_reactMapGl.Popup).withConfig({
26
+ displayName: "styled__Popup",
27
+ componentId: "sc-12v7ov3-1"
28
+ })(["& > .maplibregl-popup-content,& > .mapboxgl-popup-content{border-radius:10px;box-shadow:0 3px 14px 4px rgb(0 0 0 / 20%);}"]);
29
+ exports.Popup = Popup;
30
+
31
+ const MapOverlayPopup = _styledComponents.default.div.withConfig({
32
+ displayName: "styled__MapOverlayPopup",
33
+ componentId: "sc-12v7ov3-2"
34
+ })(["font-size:12px;line-height:1.5;min-width:250px;"]);
35
+
36
+ exports.MapOverlayPopup = MapOverlayPopup;
37
+
38
+ const PopupRow = _styledComponents.default.p.withConfig({
39
+ displayName: "styled__PopupRow",
40
+ componentId: "sc-12v7ov3-3"
41
+ })(["margin-top:6px;"]);
42
+
43
+ exports.PopupRow = PopupRow;
44
+
45
+ const PopupTitle = _styledComponents.default.header.withConfig({
46
+ displayName: "styled__PopupTitle",
47
+ componentId: "sc-12v7ov3-4"
48
+ })(["font-size:18px;font-weight:500;margin-bottom:6px;"]);
49
+
50
+ exports.PopupTitle = PopupTitle;
19
51
  //# sourceMappingURL=styled.js.map
package/lib/styled.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/styled.ts"],"names":["ViewStopButton","styled","button"],"mappings":";;;;;;;;;AAAA;;AAEA;AACO,MAAMA,cAAc,GAAGC,0BAAOC,MAAV;AAAA;AAAA;AAAA,qKAApB","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"],"file":"styled.js"}
1
+ {"version":3,"sources":["../src/styled.ts"],"names":["ViewStopButton","styled","button","Popup","MapGlPopup","MapOverlayPopup","div","PopupRow","p","PopupTitle","header"],"mappings":";;;;;;;;;AAAA;;AAEA;;AAEA;AACO,MAAMA,cAAc,GAAGC,0BAAOC,MAAV;AAAA;AAAA;AAAA,qKAApB;AAYP;AACA;AACA;;;;AACO,MAAMC,KAAK,GAAG,+BAAOC,iBAAP,CAAH;AAAA;AAAA;AAAA,iIAAX;;;AAQA,MAAMC,eAAe,GAAGJ,0BAAOK,GAAV;AAAA;AAAA;AAAA,uDAArB;;;;AAMA,MAAMC,QAAQ,GAAGN,0BAAOO,CAAV;AAAA;AAAA;AAAA,uBAAd;;;;AAIA,MAAMC,UAAU,GAAGR,0BAAOS,MAAV;AAAA;AAAA;AAAA,yDAAhB","sourcesContent":["import styled from \"styled-components\";\n\nimport { Popup as MapGlPopup } from \"react-map-gl\";\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\n/**\n * Adds a box shadow and tweaks border radius to make popups easier to read.\n */\nexport const Popup = styled(MapGlPopup)`\n & > .maplibregl-popup-content,\n & > .mapboxgl-popup-content {\n border-radius: 10px;\n box-shadow: 0 3px 14px 4px rgb(0 0 0 / 20%);\n }\n`;\n\nexport const MapOverlayPopup = styled.div`\n font-size: 12px;\n line-height: 1.5;\n min-width: 250px;\n`;\n\nexport const PopupRow = styled.p`\n margin-top: 6px;\n`;\n\nexport const PopupTitle = styled.header`\n font-size: 18px;\n font-weight: 500;\n margin-bottom: 6px;\n`;\n"],"file":"styled.js"}
package/lib/util.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,SAAS,EACf,sBAAsB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,YAGvC,OAAO,GAAG,IAAI,mBACL,OAAO,EAAE,KACzB,MAAM,GAAG,IAAI,CAsDjB"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,SAAS,EACf,sBAAsB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,YAGvC,OAAO,GAAG,IAAI,mBACL,OAAO,EAAE,KACzB,MAAM,GAAG,IAAI,CAwDjB"}
package/lib/util.js CHANGED
@@ -14,6 +14,8 @@ function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
14
14
  return function defaultGetEntityName(entity, configCompanies) {
15
15
  var _entity$networks;
16
16
 
17
+ // TODO: Stop generating this / passing it to the car string? Is it needed?
18
+ // In English we say "Car: " instead
17
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 ? void 0 : (_entity$networks = entity.networks) === null || _entity$networks === void 0 ? void 0 : _entity$networks[0]));
18
20
  let stationName = entity.name || entity.id; // If the station name or id is a giant UUID (with more than 3 "-" characters)
19
21
  // best not to show that at all. The company name will still be shown.
@@ -29,7 +31,7 @@ function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
29
31
  description: "Popup title for a free-floating bike",
30
32
  id: "otpUi.MapPopup.floatingBike"
31
33
  }, {
32
- name: stationName || stationNetworks
34
+ name: stationName
33
35
  });
34
36
  } else if ("isFloatingCar" in entity && entity.isFloatingCar) {
35
37
  stationName = intl.formatMessage({
@@ -47,7 +49,7 @@ function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
47
49
  description: "Popup title for a free-floating e-scooter",
48
50
  id: "otpUi.MapPopup.floatingEScooter"
49
51
  }, {
50
- name: stationName || stationNetworks
52
+ name: stationName
51
53
  });
52
54
  }
53
55
 
package/lib/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/util.ts"],"names":["makeDefaultGetEntityName","intl","defaultEnglishMessages","defaultGetEntityName","entity","configCompanies","stationNetworks","coreUtils","itinerary","getCompaniesLabelFromNetworks","networks","stationName","name","id","match","length","isFloatingBike","formatMessage","defaultMessage","description","isFloatingCar","company","isFloatingVehicle"],"mappings":";;;;;;;;;AAEA;;AAEA;AACO,SAASA,wBAAT,CACLC,IADK,EAELC,sBAFK,EAGL;AACA,SAAO,SAASC,oBAAT,CACLC,MADK,EAELC,eAFK,EAGU;AAAA;;AACf,UAAMC,eAAe,GACnB,cAAcF,MAAd,KACCG,mBAAUC,SAAV,CAAoBC,6BAApB,CACC,CAAAL,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEM,QAAR,KAAoB,EADrB,EAECL,eAFD,MAICD,MAJD,aAICA,MAJD,2CAICA,MAAM,CAAEM,QAJT,qDAIC,iBAAmB,CAAnB,CAJD,CADD,CADF;AAOA,QAAIC,WAA0B,GAAGP,MAAM,CAACQ,IAAP,IAAeR,MAAM,CAACS,EAAvD,CARe,CASf;AACA;AACA;;AACA,QACE,CAACF,WAAW,CAACG,KAAZ,CAAkB,IAAlB,KAA2B,EAA5B,EAAgCC,MAAhC,GAAyC,CAAzC,IACAJ,WAAW,KAAK,sBAFlB,EAGE;AACAA,MAAAA,WAAW,GAAG,IAAd;AACD;;AAED,QAAI,oBAAoBP,MAApB,IAA8BA,MAAM,CAACY,cAAzC,EAAyD;AACvDL,MAAAA,WAAW,GAAGV,IAAI,CAACgB,aAAL,CACZ;AACEC,QAAAA,cAAc,EAAEhB,sBAAsB,CAAC,6BAAD,CADxC;AAEEiB,QAAAA,WAAW,EAAE,sCAFf;AAGEN,QAAAA,EAAE,EAAE;AAHN,OADY,EAMZ;AAAED,QAAAA,IAAI,EAAED,WAAW,IAAIL;AAAvB,OANY,CAAd;AAQD,KATD,MASO,IAAI,mBAAmBF,MAAnB,IAA6BA,MAAM,CAACgB,aAAxC,EAAuD;AAC5DT,MAAAA,WAAW,GAAGV,IAAI,CAACgB,aAAL,CACZ;AACEC,QAAAA,cAAc,EAAEhB,sBAAsB,CAAC,4BAAD,CADxC;AAEEiB,QAAAA,WAAW,EAAE,qCAFf;AAGEN,QAAAA,EAAE,EAAE;AAHN,OADY,EAMZ;AACEQ,QAAAA,OAAO,EAAEf,eADX;AAEEM,QAAAA,IAAI,EAAED;AAFR,OANY,CAAd;AAWD,KAZM,MAYA,IAAI,uBAAuBP,MAAvB,IAAiCA,MAAM,CAACkB,iBAA5C,EAA+D;AACpE;AACAX,MAAAA,WAAW,GAAGV,IAAI,CAACgB,aAAL,CACZ;AACEC,QAAAA,cAAc,EACZhB,sBAAsB,CAAC,iCAAD,CAF1B;AAGEiB,QAAAA,WAAW,EAAE,2CAHf;AAIEN,QAAAA,EAAE,EAAE;AAJN,OADY,EAOZ;AAAED,QAAAA,IAAI,EAAED,WAAW,IAAIL;AAAvB,OAPY,CAAd;AASD;;AACD,WAAOK,WAAP;AACD,GAxDD;AAyDD","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 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 || stationNetworks }\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 || stationNetworks }\n );\n }\n return stationName;\n };\n}\n"],"file":"util.js"}
1
+ {"version":3,"sources":["../src/util.ts"],"names":["makeDefaultGetEntityName","intl","defaultEnglishMessages","defaultGetEntityName","entity","configCompanies","stationNetworks","coreUtils","itinerary","getCompaniesLabelFromNetworks","networks","stationName","name","id","match","length","isFloatingBike","formatMessage","defaultMessage","description","isFloatingCar","company","isFloatingVehicle"],"mappings":";;;;;;;;;AAEA;;AAEA;AACO,SAASA,wBAAT,CACLC,IADK,EAELC,sBAFK,EAGL;AACA,SAAO,SAASC,oBAAT,CACLC,MADK,EAELC,eAFK,EAGU;AAAA;;AACf;AACA;AACA,UAAMC,eAAe,GACnB,cAAcF,MAAd,KACCG,mBAAUC,SAAV,CAAoBC,6BAApB,CACC,CAAAL,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEM,QAAR,KAAoB,EADrB,EAECL,eAFD,MAICD,MAJD,aAICA,MAJD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ED,QAAAA,IAAI,EAAED;AAAR,OAPY,CAAd;AASD;;AACD,WAAOA,WAAP;AACD,GA1DD;AA2DD","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"],"file":"util.js"}