@opentripplanner/map-popup 3.1.3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.js CHANGED
@@ -2,10 +2,11 @@ import React, { useCallback } from "react";
2
2
  import FromToLocationPicker from "@opentripplanner/from-to-location-picker";
3
3
  import coreUtils from "@opentripplanner/core-utils"; // eslint-disable-next-line prettier/prettier
4
4
 
5
- import { FormattedMessage, useIntl } from "react-intl";
5
+ import { FocusTrapWrapper } from "@opentripplanner/building-blocks";
6
6
  import { flatten } from "flat";
7
- import * as S from "./styled";
8
- import FocusTrapWrapper from "./FocusTrapWrapper"; // Load the default messages.
7
+ import { FormattedMessage, useIntl } from "react-intl";
8
+ import { Styled } from "@opentripplanner/base-map";
9
+ import { ViewStopButton } from "./styled"; // Load the default messages.
9
10
 
10
11
  import defaultEnglishMessages from "../i18n/en-US.yml";
11
12
  import { makeDefaultGetEntityName } from "./util"; // HACK: We should flatten the messages loaded above because
@@ -33,7 +34,7 @@ var generateLocation = function generateLocation(entity, name) {
33
34
 
34
35
  var StationHubDetails = function StationHubDetails(_ref) {
35
36
  var station = _ref.station;
36
- return /*#__PURE__*/React.createElement(S.PopupRow, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, {
37
+ return /*#__PURE__*/React.createElement(Styled.PopupRow, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, {
37
38
  defaultMessage: defaultMessages["otpUi.MapPopup.availableBikes"],
38
39
  description: "Label text for the number of bikes available",
39
40
  id: "otpUi.MapPopup.availableBikes",
@@ -53,14 +54,14 @@ var StationHubDetails = function StationHubDetails(_ref) {
53
54
  var StopDetails = function StopDetails(_ref2) {
54
55
  var id = _ref2.id,
55
56
  setViewedStop = _ref2.setViewedStop;
56
- return /*#__PURE__*/React.createElement(S.PopupRow, null, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(FormattedMessage, {
57
+ return /*#__PURE__*/React.createElement(Styled.PopupRow, null, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(FormattedMessage, {
57
58
  defaultMessage: defaultMessages["otpUi.MapPopup.stopId"],
58
59
  description: "Displays the stop id",
59
60
  id: "otpUi.MapPopup.stopId",
60
61
  values: {
61
62
  stopId: id
62
63
  }
63
- })), /*#__PURE__*/React.createElement(S.ViewStopButton, {
64
+ })), /*#__PURE__*/React.createElement(ViewStopButton, {
64
65
  onClick: setViewedStop
65
66
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
66
67
  defaultMessage: defaultMessages["otpUi.MapPopup.stopViewer"],
@@ -80,7 +81,9 @@ function entityIsStation(entity) {
80
81
  export function MapPopup(_ref3) {
81
82
  var _entity$networks;
82
83
 
83
- var configCompanies = _ref3.configCompanies,
84
+ var _ref3$closePopup = _ref3.closePopup,
85
+ closePopup = _ref3$closePopup === void 0 ? null : _ref3$closePopup,
86
+ configCompanies = _ref3.configCompanies,
84
87
  entity = _ref3.entity,
85
88
  getEntityName = _ref3.getEntityName,
86
89
  setLocation = _ref3.setLocation,
@@ -92,8 +95,13 @@ export function MapPopup(_ref3) {
92
95
  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]));
93
96
  var bikesAvailablePresent = entityIsStation(entity);
94
97
  var entityIsStationHub = bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.bikesAvailable) !== undefined && !(entity !== null && entity !== void 0 && entity.isFloatingBike);
95
- var stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code) || entity.id.split(":")[1] || entity.id;
96
- return /*#__PURE__*/React.createElement(S.MapOverlayPopup, null, /*#__PURE__*/React.createElement(S.PopupTitle, null, /*#__PURE__*/React.createElement(FormattedMessage, {
98
+ var stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code) || entity.id.split(":")[1] || entity.id; // Double quotes make the query invalid, so remove them from the id just in case
99
+
100
+ var id = "focus-".concat(entity.id, "-popup").replace(/"/g, "");
101
+ return /*#__PURE__*/React.createElement(Styled.MapOverlayPopup, null, /*#__PURE__*/React.createElement(FocusTrapWrapper, {
102
+ closePopup: closePopup,
103
+ id: id
104
+ }, /*#__PURE__*/React.createElement(Styled.PopupTitle, null, /*#__PURE__*/React.createElement(FormattedMessage, {
97
105
  defaultMessage: defaultMessages["otpUi.MapPopup.popupTitle"],
98
106
  description: "Text for title of the popup, contains an optional company name",
99
107
  id: "otpUi.MapPopup.popupTitle",
@@ -108,13 +116,11 @@ export function MapPopup(_ref3) {
108
116
  setViewedStop: useCallback(function () {
109
117
  return setViewedStop(entity);
110
118
  }, [entity])
111
- }), setLocation && /*#__PURE__*/React.createElement(S.PopupRow, null, /*#__PURE__*/React.createElement(FromToLocationPicker, {
119
+ }), setLocation && /*#__PURE__*/React.createElement(Styled.PopupRow, null, /*#__PURE__*/React.createElement(FromToLocationPicker, {
112
120
  label: true,
113
121
  location: generateLocation(entity, name),
114
122
  setLocation: setLocation
115
- })));
123
+ }))));
116
124
  }
117
- export default MapPopup; // Rename styled components for export.
118
-
119
- export { S as Styled, FocusTrapWrapper };
125
+ export default MapPopup;
120
126
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
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","getCompaniesLabelFromNetwor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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"}
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","setLocation","intl","getNameFunc","stationNetwork","itinerary","getCompaniesLabelFromNetworks","networks","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","split","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,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;;AA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CAAUoB,KAAV,CAAgB,GAAhB,EAAqB,CAArB,CAA1C,IAAqElC,MAAM,CAACc,EAA3F,CAXsI,CAatI;;AACA,MAAMA,EAAE,GAAG,gBAASd,MAAM,CAACc,EAAhB,YAA2BqB,OAA3B,CAAmC,IAAnC,EAAyC,EAAzC,CAAX;AAEA,sBACE,oBAAC,MAAD,CAAQ,eAAR,qBACE,oBAAC,gBAAD;AAAkB,IAAA,UAAU,EAAEhB,UAA9B;AAA0C,IAAA,EAAE,EAAEL;AAA9C,kBACA,oBAAC,MAAD,CAAQ,UAAR,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;AAAQwB,MAAAA,cAAc,EAAdA;AAAR;AAJV,IADF,CADA,EAUCK,kBAAkB,iBAAI,oBAAC,iBAAD;AAAmB,IAAA,OAAO,EAAE9B;AAA5B,IAVvB,EAaCe,aAAa,IAAI,CAACc,qBAAlB,iBACC,oBAAC,WAAD;AACE,IAAA,EAAE,EAAEb,MADN;AAEE,IAAA,aAAa,EAAE7B,WAAW,CAAC;AAAA,aAAM4B,aAAa,CAACf,MAAD,CAAnB;AAAA,KAAD,EAA8B,CAACA,MAAD,CAA9B;AAF5B,IAdF,EAqBCsB,WAAW,iBACV,oBAAC,MAAD,CAAQ,QAAR,qBACE,oBAAC,oBAAD;AACE,IAAA,KAAK,MADP;AAEE,IAAA,QAAQ,EAAEvB,gBAAgB,CAACC,MAAD,EAASC,IAAT,CAF5B;AAGE,IAAA,WAAW,EAAEqB;AAHf,IADF,CAtBF,CADF,CADF;AAoCD;AAED,eAAeJ,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 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 = null, 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 // Double quotes make the query invalid, so remove them from the id just in case\n const id = `focus-${entity.id}-popup`.replace(/\"/g, \"\")\n\n return (\n <Styled.MapOverlayPopup>\n <FocusTrapWrapper closePopup={closePopup} id={id}>\n <Styled.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 </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"}
package/esm/styled.js CHANGED
@@ -1,29 +1,8 @@
1
1
  import styled from "styled-components";
2
- import { Popup as MapGlPopup } from "react-map-gl";
3
2
  /* eslint-disable-next-line import/prefer-default-export */
4
3
 
5
4
  export var ViewStopButton = styled.button.withConfig({
6
5
  displayName: "styled__ViewStopButton",
7
6
  componentId: "sc-12v7ov3-0"
8
7
  })(["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;"]);
29
8
  //# sourceMappingURL=styled.js.map
package/esm/styled.js.map CHANGED
@@ -1 +1 @@
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"}
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"}
package/lib/index.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from "@opentripplanner/types";
3
- import * as S from "./styled";
4
- import FocusTrapWrapper from "./FocusTrapWrapper";
5
3
  export declare const defaultMessages: {
6
4
  [key: string]: string;
7
5
  };
8
6
  declare type Entity = Stop | Station;
9
7
  declare type Props = {
8
+ closePopup?: (arg?: any) => void;
10
9
  configCompanies?: ConfiguredCompany[];
11
10
  entity: Entity;
12
11
  getEntityName?: (entity: Entity, configCompanies: Company[]) => string;
@@ -19,7 +18,6 @@ declare type Props = {
19
18
  /**
20
19
  * Renders a map popup for a stop, scooter, or shared bike
21
20
  */
22
- export declare function MapPopup({ configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element;
21
+ export declare function MapPopup({ closePopup, configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element;
23
22
  export default MapPopup;
24
- export { S as Styled, FocusTrapWrapper };
25
23
  //# sourceMappingURL=index.d.ts.map
@@ -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,MA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,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,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,UAAiB,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAoDtI;AAED,eAAe,QAAQ,CAAC"}
package/lib/index.js CHANGED
@@ -6,13 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.MapPopup = MapPopup;
9
- Object.defineProperty(exports, "FocusTrapWrapper", {
10
- enumerable: true,
11
- get: function () {
12
- return _FocusTrapWrapper.default;
13
- }
14
- });
15
- exports.Styled = exports.default = exports.defaultMessages = void 0;
9
+ exports.default = exports.defaultMessages = void 0;
16
10
 
17
11
  var _react = _interopRequireWildcard(require("react"));
18
12
 
@@ -20,15 +14,15 @@ var _fromToLocationPicker = _interopRequireDefault(require("@opentripplanner/fro
20
14
 
21
15
  var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
22
16
 
23
- var _reactIntl = require("react-intl");
17
+ var _buildingBlocks = require("@opentripplanner/building-blocks");
24
18
 
25
19
  var _flat = require("flat");
26
20
 
27
- var S = _interopRequireWildcard(require("./styled"));
21
+ var _reactIntl = require("react-intl");
28
22
 
29
- exports.Styled = S;
23
+ var _baseMap = require("@opentripplanner/base-map");
30
24
 
31
- var _FocusTrapWrapper = _interopRequireDefault(require("./FocusTrapWrapper"));
25
+ var _styled = require("./styled");
32
26
 
33
27
  var _enUS = _interopRequireDefault(require("../i18n/en-US.yml"));
34
28
 
@@ -67,7 +61,7 @@ const generateLocation = (entity, name) => {
67
61
  const StationHubDetails = ({
68
62
  station
69
63
  }) => {
70
- return /*#__PURE__*/_react.default.createElement(S.PopupRow, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
64
+ return /*#__PURE__*/_react.default.createElement(_baseMap.Styled.PopupRow, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
71
65
  defaultMessage: defaultMessages["otpUi.MapPopup.availableBikes"],
72
66
  description: "Label text for the number of bikes available",
73
67
  id: "otpUi.MapPopup.availableBikes",
@@ -88,14 +82,14 @@ const StopDetails = ({
88
82
  id,
89
83
  setViewedStop
90
84
  }) => {
91
- return /*#__PURE__*/_react.default.createElement(S.PopupRow, null, /*#__PURE__*/_react.default.createElement("strong", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
85
+ return /*#__PURE__*/_react.default.createElement(_baseMap.Styled.PopupRow, null, /*#__PURE__*/_react.default.createElement("strong", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
92
86
  defaultMessage: defaultMessages["otpUi.MapPopup.stopId"],
93
87
  description: "Displays the stop id",
94
88
  id: "otpUi.MapPopup.stopId",
95
89
  values: {
96
90
  stopId: id
97
91
  }
98
- })), /*#__PURE__*/_react.default.createElement(S.ViewStopButton, {
92
+ })), /*#__PURE__*/_react.default.createElement(_styled.ViewStopButton, {
99
93
  onClick: setViewedStop
100
94
  }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
101
95
  defaultMessage: defaultMessages["otpUi.MapPopup.stopViewer"],
@@ -113,6 +107,7 @@ function entityIsStation(entity) {
113
107
 
114
108
 
115
109
  function MapPopup({
110
+ closePopup = null,
116
111
  configCompanies,
117
112
  entity,
118
113
  getEntityName,
@@ -128,8 +123,13 @@ function MapPopup({
128
123
  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]));
129
124
  const bikesAvailablePresent = entityIsStation(entity);
130
125
  const entityIsStationHub = bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.bikesAvailable) !== undefined && !(entity !== null && entity !== void 0 && entity.isFloatingBike);
131
- const stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code) || entity.id.split(":")[1] || entity.id;
132
- return /*#__PURE__*/_react.default.createElement(S.MapOverlayPopup, null, /*#__PURE__*/_react.default.createElement(S.PopupTitle, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
126
+ const stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code) || entity.id.split(":")[1] || entity.id; // Double quotes make the query invalid, so remove them from the id just in case
127
+
128
+ const id = `focus-${entity.id}-popup`.replace(/"/g, "");
129
+ return /*#__PURE__*/_react.default.createElement(_baseMap.Styled.MapOverlayPopup, null, /*#__PURE__*/_react.default.createElement(_buildingBlocks.FocusTrapWrapper, {
130
+ closePopup: closePopup,
131
+ id: id
132
+ }, /*#__PURE__*/_react.default.createElement(_baseMap.Styled.PopupTitle, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
133
133
  defaultMessage: defaultMessages["otpUi.MapPopup.popupTitle"],
134
134
  description: "Text for title of the popup, contains an optional company name",
135
135
  id: "otpUi.MapPopup.popupTitle",
@@ -142,14 +142,13 @@ function MapPopup({
142
142
  }), setViewedStop && !bikesAvailablePresent && /*#__PURE__*/_react.default.createElement(StopDetails, {
143
143
  id: stopId,
144
144
  setViewedStop: (0, _react.useCallback)(() => setViewedStop(entity), [entity])
145
- }), setLocation && /*#__PURE__*/_react.default.createElement(S.PopupRow, null, /*#__PURE__*/_react.default.createElement(_fromToLocationPicker.default, {
145
+ }), setLocation && /*#__PURE__*/_react.default.createElement(_baseMap.Styled.PopupRow, null, /*#__PURE__*/_react.default.createElement(_fromToLocationPicker.default, {
146
146
  label: true,
147
147
  location: generateLocation(entity, name),
148
148
  setLocation: setLocation
149
- })));
149
+ }))));
150
150
  }
151
151
 
152
- var _default = MapPopup; // Rename styled components for export.
153
-
152
+ var _default = MapPopup;
154
153
  exports.default = _default;
155
154
  //# 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","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,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AAM,CAACc,EAA3F;AAEA,sBACE,6BAAC,CAAD,CAAG,eAAH,qBACE,6BAAC,CAAD,CAAG,UAAH,qBACE,6BAAC,2BAAD;AACE,IAAA,cAAc,EAAEjB,eAAe,CAAC,2BAAD,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"}
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","setLocation","intl","getNameFunc","stationNetwork","coreUtils","itinerary","getCompaniesLabelFromNetworks","networks","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","split","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;AAAEa,MAAAA,KAAK,EAAED,OAAO,CAACE;AAAjB;AANV,IADF,CADF,eAWE,uDACE,6BAAC,2BAAD;AACE,IAAA,cAAc,EACZd,eAAe,CAAC,+BAAD,CAFnB;AAIE,IAAA,WAAW,EAAC,8CAJd;AAKE,IAAA,EAAE,EAAC,+BALL;AAME,IAAA,MAAM,EAAE;AAAEa,MA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EAaCe,aAAa,IAAI,CAACe,qBAAlB,iBACC,6BAAC,WAAD;AACE,IAAA,EAAE,EAAEd,MADN;AAEE,IAAA,aAAa,EAAE,wBAAY,MAAMD,aAAa,CAACf,MAAD,CAA/B,EAAyC,CAACA,MAAD,CAAzC;AAFjB,IAdF,EAqBCsB,WAAW,iBACV,6BAAC,eAAD,CAAQ,QAAR,qBACE,6BAAC,6BAAD;AACE,IAAA,KAAK,MADP;AAEE,IAAA,QAAQ,EAAEvB,gBAAgB,CAACC,MAAD,EAASC,IAAT,CAF5B;AAGE,IAAA,WAAW,EAAEqB;AAHf,IADF,CAtBF,CADF,CADF;AAoCD;;eAEcJ,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 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 = null, 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 // Double quotes make the query invalid, so remove them from the id just in case\n const id = `focus-${entity.id}-popup`.replace(/\"/g, \"\")\n\n return (\n <Styled.MapOverlayPopup>\n <FocusTrapWrapper closePopup={closePopup} id={id}>\n <Styled.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 </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"}
package/lib/styled.d.ts CHANGED
@@ -1,10 +1,2 @@
1
- /// <reference types="react" />
2
1
  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>;
10
2
  //# sourceMappingURL=styled.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,uEAU1B,CAAC"}
package/lib/styled.js CHANGED
@@ -5,47 +5,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.PopupTitle = exports.PopupRow = exports.MapOverlayPopup = exports.Popup = exports.ViewStopButton = void 0;
8
+ exports.ViewStopButton = void 0;
9
9
 
10
10
  var _styledComponents = _interopRequireDefault(require("styled-components"));
11
11
 
12
- var _reactMapGl = require("react-map-gl");
13
-
14
12
  /* eslint-disable-next-line import/prefer-default-export */
15
13
  const ViewStopButton = _styledComponents.default.button.withConfig({
16
14
  displayName: "styled__ViewStopButton",
17
15
  componentId: "sc-12v7ov3-0"
18
16
  })(["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
-
23
17
 
24
18
  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;
51
19
  //# sourceMappingURL=styled.js.map
package/lib/styled.js.map CHANGED
@@ -1 +1 @@
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"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentripplanner/map-popup",
3
- "version": "3.1.3",
3
+ "version": "4.0.0",
4
4
  "description": "A component for displaying map popup contents",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -11,6 +11,8 @@
11
11
  "license": "MIT",
12
12
  "private": false,
13
13
  "dependencies": {
14
+ "@opentripplanner/base-map": "^3.2.1",
15
+ "@opentripplanner/building-blocks": "^1.2.2",
14
16
  "@opentripplanner/core-utils": "^11.4.3",
15
17
  "@opentripplanner/from-to-location-picker": "^2.1.13",
16
18
  "flat": "^5.0.2"
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { action } from "@storybook/addon-actions";
3
- import MapPopupContents, { FocusTrapWrapper } from "./index";
3
+ import MapPopupContents from "./index";
4
4
 
5
5
  export default {
6
6
  title: "Map Popup"
@@ -95,13 +95,3 @@ export const FloatingVehicleEntity = (): JSX.Element => (
95
95
  setViewedStop={action("setViewedStop")}
96
96
  />
97
97
  );
98
-
99
- export const StopEntityWithFocusTrap = (): JSX.Element => (
100
- <FocusTrapWrapper closePopup={() => {}} id="storybook-stop">
101
- <MapPopupContents
102
- entity={STOP}
103
- setLocation={action("setLocation")}
104
- setViewedStop={action("setViewedStop")}
105
- />
106
- </FocusTrapWrapper>
107
- );