@opentripplanner/map-popup 6.1.0-alpha.2 → 6.1.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 +18 -7
- package/esm/index.js.map +1 -1
- package/esm/styled.js +3 -1
- package/esm/styled.js.map +1 -1
- package/esm/util.js +3 -2
- package/esm/util.js.map +1 -1
- package/i18n/es.yml +1 -1
- package/i18n/fr.yml +1 -1
- package/i18n/ko.yml +1 -1
- package/i18n/pl.yml +10 -1
- package/i18n/ta.yml +8 -9
- package/i18n/vi.yml +1 -1
- package/i18n/zh_Hans.yml +1 -1
- package/lib/index.d.ts +11 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +16 -7
- package/lib/index.js.map +1 -1
- package/lib/styled.d.ts +3 -1
- package/lib/styled.d.ts.map +1 -1
- package/lib/styled.js +1 -1
- package/lib/styled.js.map +1 -1
- package/lib/util.d.ts +3 -2
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +3 -1
- package/lib/util.js.map +1 -1
- package/package.json +6 -6
- package/src/MapPopup.story.tsx +66 -6
- package/src/__snapshots__/MapPopup.story.tsx.snap +130 -3
- package/src/index.tsx +46 -19
- package/src/styled.ts +5 -3
- package/src/util.ts +7 -2
- package/tsconfig.json +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/README.md +0 -6
package/esm/index.js
CHANGED
|
@@ -55,7 +55,7 @@ var StationHubDetails = function StationHubDetails(_ref) {
|
|
|
55
55
|
var StopDetails = function StopDetails(_ref2) {
|
|
56
56
|
var id = _ref2.id,
|
|
57
57
|
setViewedStop = _ref2.setViewedStop;
|
|
58
|
-
return /*#__PURE__*/React.createElement(Styled.PopupRow, null, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
58
|
+
return /*#__PURE__*/React.createElement(Styled.PopupRow, null, id && /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
59
59
|
defaultMessage: defaultMessages["otpUi.MapPopup.stopId"],
|
|
60
60
|
description: "Displays the stop id",
|
|
61
61
|
id: "otpUi.MapPopup.stopId",
|
|
@@ -63,7 +63,8 @@ var StopDetails = function StopDetails(_ref2) {
|
|
|
63
63
|
stopId: id
|
|
64
64
|
}
|
|
65
65
|
})), /*#__PURE__*/React.createElement(ViewStopButton, {
|
|
66
|
-
onClick: setViewedStop
|
|
66
|
+
onClick: setViewedStop,
|
|
67
|
+
stopId: id
|
|
67
68
|
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
68
69
|
defaultMessage: defaultMessages["otpUi.MapPopup.stopViewer"],
|
|
69
70
|
description: "Text for link that opens the stop viewer",
|
|
@@ -86,17 +87,27 @@ export function MapPopup(_ref3) {
|
|
|
86
87
|
getEntityName = _ref3.getEntityName,
|
|
87
88
|
getEntityPrefix = _ref3.getEntityPrefix,
|
|
88
89
|
setLocation = _ref3.setLocation,
|
|
89
|
-
setViewedStop = _ref3.setViewedStop
|
|
90
|
+
setViewedStop = _ref3.setViewedStop,
|
|
91
|
+
feeds = _ref3.feeds;
|
|
90
92
|
var intl = useIntl();
|
|
91
93
|
if (!entity) return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
92
94
|
var getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);
|
|
93
|
-
|
|
95
|
+
|
|
96
|
+
// Find the feed name using the logic from generateLabel in otp.ts
|
|
97
|
+
var feedName;
|
|
98
|
+
if (feeds && entity.id) {
|
|
99
|
+
var _feed$publisher;
|
|
100
|
+
var feedId = entity.id.split(":")[0];
|
|
101
|
+
var feed = feeds.find(function (f) {
|
|
102
|
+
return f.feedId === feedId;
|
|
103
|
+
});
|
|
104
|
+
feedName = feed === null || feed === void 0 || (_feed$publisher = feed.publisher) === null || _feed$publisher === void 0 ? void 0 : _feed$publisher.name;
|
|
105
|
+
}
|
|
106
|
+
var name = getNameFunc(entity, configCompanies, feedName);
|
|
94
107
|
var stationNetwork = "networks" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0 || (_entity$networks = entity.networks) === null || _entity$networks === void 0 ? void 0 : _entity$networks[0]));
|
|
95
108
|
var bikesAvailablePresent = entityIsStation(entity);
|
|
96
109
|
var entityIsStationHub = bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.bikesAvailable) !== undefined && !(entity !== null && entity !== void 0 && entity.isFloatingBike);
|
|
97
|
-
var stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code)
|
|
98
|
-
|
|
99
|
-
// Double quotes make the query invalid, so remove them from the id just in case
|
|
110
|
+
var stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code);
|
|
100
111
|
var id = "focus-".concat(encodeURIComponent(entity.id).replace(/%/g, ""), "-popup");
|
|
101
112
|
return /*#__PURE__*/React.createElement(Styled.MapOverlayPopup, null, /*#__PURE__*/React.createElement(FocusTrapWrapper, {
|
|
102
113
|
closePopup: closePopup,
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","FromToLocationPicker","coreUtils","FocusTrapWrapper","flatten","FormattedMessage","useIntl","Styled","ViewStopButton","defaultEnglishMessages","makeDefaultGetEntityName","defaultMessages","generateLocation","entity","name","entityLon","lon","entityLat","lat","x","y","StationHubDetails","_ref","station","createElement","PopupRow","defaultMessage","description","id","values","value","bikesAvailable","spacesAvailable","StopDetails","_ref2","setViewedStop","stopId","onClick","entityIsStation","MapPopup","_ref3","_entity$networks","_ref3$closePopup","closePopup","configCompanies","getEntityName","getEntityPrefix","setLocation","intl","Fragment","getNameFunc","stationNetwork","itinerary","getCompaniesLabelFromNetworks","networks","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","split","concat","encodeURIComponent","replace","MapOverlayPopup","PopupTitle","label","location"],"sources":["../src/index.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport FromToLocationPicker from \"@opentripplanner/from-to-location-picker\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\n// eslint-disable-next-line prettier/prettier\nimport type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from \"@opentripplanner/types\";\n\nimport { FocusTrapWrapper } from \"@opentripplanner/building-blocks\";\nimport { flatten } from \"flat\";\nimport { FormattedMessage, useIntl } from \"react-intl\";\nimport { Styled } from \"@opentripplanner/base-map\";\n\nimport { ViewStopButton } from \"./styled\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\nimport { makeDefaultGetEntityName } from \"./util\";\n\n// HACK: We should flatten the messages loaded above because\n// the YAML loaders behave differently between webpack and our version of jest:\n// - the yaml loader for webpack returns a nested object,\n// - the yaml loader for jest returns messages with flattened ids.\nexport const defaultMessages: { [key: string]: string } = flatten(defaultEnglishMessages);\n\nconst generateLocation = (entity: Entity, name: string) => {\n // @ts-expect-error some of these values may be null, but that's ok\n const { lon: entityLon, lat: entityLat, x, y } = entity\n\n const lat = entityLat || y\n const lon = entityLon || x\n if (!lat || !lon) return null\n\n return { lat, lon, name };\n}\n\nconst StationHubDetails = ({ station }: { station: Station }) => {\n return (\n <Styled.PopupRow>\n <div>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.MapPopup.availableBikes\"]\n }\n description=\"Label text for the number of bikes available\"\n id=\"otpUi.MapPopup.availableBikes\"\n values={{ value: station.bikesAvailable }}\n />\n </div>\n <div>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.MapPopup.availableDocks\"]\n }\n description=\"Label text for the number of docks available\"\n id=\"otpUi.MapPopup.availableDocks\"\n values={{ value: station.spacesAvailable }}\n />\n </div>\n </Styled.PopupRow>\n )\n}\n\nconst StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {\n return (\n <Styled.PopupRow>\n <strong>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.stopId\"]}\n description=\"Displays the stop id\"\n id=\"otpUi.MapPopup.stopId\"\n values={{\n stopId: id\n }}\n />\n </strong>\n <ViewStopButton onClick={setViewedStop}>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.stopViewer\"]}\n description=\"Text for link that opens the stop viewer\"\n id=\"otpUi.MapPopup.stopViewer\"\n />\n </ViewStopButton>\n </Styled.PopupRow>\n )\n}\n\ntype Entity = Stop | Station\ntype Props = {\n closePopup?: (arg?: any) => void\n configCompanies?: ConfiguredCompany[];\n entity: Entity\n getEntityName?: (entity: Entity, configCompanies: Company[],) => string;\n getEntityPrefix?: (entity: Entity) => JSX.Element\n setLocation?: ({ location, locationType }: { location: Location, locationType: string }) => void;\n setViewedStop?: StopEventHandler;\n};\n\nfunction entityIsStation(entity: Entity): entity is Station {\n return \"bikesAvailable\" in entity\n}\n\n/**\n * Renders a map popup for a stop, scooter, or shared bike\n */\nexport function MapPopup({ closePopup = () => {}, configCompanies, entity, getEntityName, getEntityPrefix, setLocation, setViewedStop }: Props): JSX.Element {\n\n const intl = useIntl()\n if (!entity) return <></>\n\n const getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);\n const name = getNameFunc(entity, configCompanies);\n\n const stationNetwork = \"networks\" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks(entity?.networks || [], configCompanies) || entity?.networks?.[0]);\n\n const bikesAvailablePresent = entityIsStation(entity)\n const entityIsStationHub = bikesAvailablePresent && entity?.bikesAvailable !== undefined && !entity?.isFloatingBike;\n const stopId = !bikesAvailablePresent && entity?.code || entity.id.split(\":\")[1] || entity.id\n\n // Double quotes make the query invalid, so remove them from the id just in case\n const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, \"\")}-popup`\n\n return (\n <Styled.MapOverlayPopup>\n <FocusTrapWrapper closePopup={closePopup} id={id}>\n <Styled.PopupTitle>\n {getEntityPrefix && getEntityPrefix(entity)}\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.popupTitle\"]}\n description=\"Text for title of the popup, contains an optional company name\"\n id=\"otpUi.MapPopup.popupTitle\"\n values={{ name, stationNetwork }}\n />\n </Styled.PopupTitle>\n {/* render dock info if it is available */}\n {entityIsStationHub && <StationHubDetails station={entity} />}\n\n {/* render stop viewer link if available */}\n {setViewedStop && !bikesAvailablePresent && (\n <StopDetails\n id={stopId}\n setViewedStop={useCallback(() => setViewedStop(entity), [entity])}\n />\n )}\n\n {/* The \"Set as [from/to]\" ButtonGroup */}\n {setLocation && (\n <Styled.PopupRow>\n <FromToLocationPicker\n label\n location={generateLocation(entity, name)}\n setLocation={setLocation}\n />\n </Styled.PopupRow>\n )}\n </FocusTrapWrapper>\n \n </Styled.MapOverlayPopup>\n );\n}\n\nexport default MapPopup;"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,OAAOC,oBAAoB,MAAM,0CAA0C;AAC3E,OAAOC,SAAS,MAAM,6BAA6B;;AAEnD;;AAGA,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,OAAO,QAAQ,MAAM;AAC9B,SAASC,gBAAgB,EAAEC,OAAO,QAAQ,YAAY;AACtD,SAASC,MAAM,QAAQ,2BAA2B;AAElD,SAASC,cAAc,QAAQ,UAAU;;AAEzC;AACA,OAAOC,sBAAsB,MAAM,mBAAmB;AACtD,SAASC,wBAAwB,QAAQ,QAAQ;;AAEjD;AACA;AACA;AACA;AACA,OAAO,IAAMC,eAA0C,GAAGP,OAAO,CAACK,sBAAsB,CAAC;AAEzF,IAAMG,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,MAAc,EAAEC,IAAY,EAAK;EACzD;EACA,IAAaC,SAAS,GAA2BF,MAAM,CAA/CG,GAAG;IAAkBC,SAAS,GAAWJ,MAAM,CAA/BK,GAAG;IAAaC,CAAC,GAAQN,MAAM,CAAfM,CAAC;IAAEC,CAAC,GAAKP,MAAM,CAAZO,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c,EAAEf,eAAe,CAAC,2BAA2B,CAAE;IAC7DgB,WAAW,EAAC,gEAAgE;IAC5EC,EAAE,EAAC,2BAA2B;IAC9BC,MAAM,EAAE;MAAEf,IAAI,EAAJA,IAAI;MAAEqC,cAAc,EAAdA;IAAe;EAAE,CAClC,CACgB,CAAC,EAEnBK,kBAAkB,iBAAIzD,KAAA,CAAAyB,aAAA,CAACH,iBAAiB;IAACE,OAAO,EAAEV;EAAO,CAAE,CAAC,EAG5DsB,aAAa,IAAI,CAACoB,qBAAqB,iBACtCxD,KAAA,CAAAyB,aAAA,CAACS,WAAW;IACVL,EAAE,EAAEQ,MAAO;IACXD,aAAa,EAAEnC,WAAW,CAAC;MAAA,OAAMmC,aAAa,CAACtB,MAAM,CAAC;IAAA,GAAE,CAACA,MAAM,CAAC;EAAE,CACnE,CACF,EAGAkC,WAAW,iBACVhD,KAAA,CAAAyB,aAAA,CAACjB,MAAM,CAACkB,QAAQ,qBACd1B,KAAA,CAAAyB,aAAA,CAACvB,oBAAoB;IACnBiE,KAAK;IACLC,QAAQ,EAAEvD,gBAAgB,CAACC,MAAM,EAAEC,IAAI,CAAE;IACzCiC,WAAW,EAAEA;EAAY,CAC1B,CACc,CAED,CAEI,CAAC;AAE7B;AAEA,eAAeR,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","FromToLocationPicker","coreUtils","FocusTrapWrapper","flatten","FormattedMessage","useIntl","Styled","ViewStopButton","defaultEnglishMessages","makeDefaultGetEntityName","defaultMessages","generateLocation","entity","name","entityLon","lon","entityLat","lat","x","y","StationHubDetails","_ref","station","createElement","PopupRow","defaultMessage","description","id","values","value","bikesAvailable","spacesAvailable","StopDetails","_ref2","setViewedStop","stopId","onClick","entityIsStation","MapPopup","_ref3","_entity$networks","_ref3$closePopup","closePopup","configCompanies","getEntityName","getEntityPrefix","setLocation","feeds","intl","Fragment","getNameFunc","feedName","_feed$publisher","feedId","split","feed","find","f","publisher","stationNetwork","itinerary","getCompaniesLabelFromNetworks","networks","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","concat","encodeURIComponent","replace","MapOverlayPopup","PopupTitle","label","location"],"sources":["../src/index.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport FromToLocationPicker from \"@opentripplanner/from-to-location-picker\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\n// eslint-disable-next-line prettier/prettier\nimport type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from \"@opentripplanner/types\";\n\nimport { FocusTrapWrapper } from \"@opentripplanner/building-blocks\";\nimport { flatten } from \"flat\";\nimport { FormattedMessage, useIntl } from \"react-intl\";\nimport { Styled } from \"@opentripplanner/base-map\";\n\nimport { ViewStopButton } from \"./styled\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\nimport { makeDefaultGetEntityName, type StopIdAgencyMap } 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\nexport type Feed = {\n feedId: string;\n publisher: {\n name: string;\n };\n};\n\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 {id &&\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} stopId={id}> \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[], feedName?: string) => string;\n getEntityPrefix?: (entity: Entity) => JSX.Element\n feeds?: Feed[]\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({ \n closePopup = () => {}, \n configCompanies, \n entity, \n getEntityName, \n getEntityPrefix, \n setLocation, \n setViewedStop, \n feeds,\n}: Props): JSX.Element {\n\n const intl = useIntl()\n if (!entity) return <></>\n\n const getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);\n \n // Find the feed name using the logic from generateLabel in otp.ts\n let feedName: string | undefined;\n if (feeds && entity.id) {\n const feedId = entity.id.split(\":\")[0];\n const feed = feeds.find(f => f.feedId === feedId);\n feedName = feed?.publisher?.name;\n }\n \n const name = getNameFunc(entity, configCompanies, feedName);\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;\n const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, \"\")}-popup`\n\n return (\n <Styled.MapOverlayPopup>\n <FocusTrapWrapper closePopup={closePopup} id={id}>\n <Styled.PopupTitle>\n {getEntityPrefix && getEntityPrefix(entity)}\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.popupTitle\"]}\n description=\"Text for title of the popup, contains an optional company name\"\n id=\"otpUi.MapPopup.popupTitle\"\n values={{ name, stationNetwork }}\n />\n </Styled.PopupTitle>\n {/* render dock info if it is available */}\n {entityIsStationHub && <StationHubDetails station={entity} />}\n\n {/* render stop viewer link if available */}\n {setViewedStop && !bikesAvailablePresent && (\n <StopDetails\n id={stopId}\n setViewedStop={useCallback(() => setViewedStop(entity), [entity])}\n />\n )}\n\n {/* The \"Set as [from/to]\" ButtonGroup */}\n {setLocation && (\n <Styled.PopupRow>\n <FromToLocationPicker\n label\n location={generateLocation(entity, name)}\n setLocation={setLocation}\n />\n </Styled.PopupRow>\n )}\n </FocusTrapWrapper>\n \n </Styled.MapOverlayPopup>\n );\n}\n\nexport default MapPopup;\nexport { type StopIdAgencyMap };"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,OAAOC,oBAAoB,MAAM,0CAA0C;AAC3E,OAAOC,SAAS,MAAM,6BAA6B;;AAEnD;;AAGA,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,OAAO,QAAQ,MAAM;AAC9B,SAASC,gBAAgB,EAAEC,OAAO,QAAQ,YAAY;AACtD,SAASC,MAAM,QAAQ,2BAA2B;AAElD,SAASC,cAAc,QAAQ,UAAU;;AAEzC;AACA,OAAOC,sBAAsB,MAAM,mB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AA,OAAMmC,aAAa,CAACtB,MAAM,CAAC;IAAA,GAAE,CAACA,MAAM,CAAC;EAAE,CACnE,CACF,EAGAkC,WAAW,iBACVhD,KAAA,CAAAyB,aAAA,CAACjB,MAAM,CAACkB,QAAQ,qBACd1B,KAAA,CAAAyB,aAAA,CAACvB,oBAAoB;IACnByE,KAAK;IACLC,QAAQ,EAAE/D,gBAAgB,CAACC,MAAM,EAAEC,IAAI,CAAE;IACzCiC,WAAW,EAAEA;EAAY,CAC1B,CACc,CAED,CAEI,CAAC;AAE7B;AAEA,eAAeR,QAAQ","ignoreList":[]}
|
package/esm/styled.js
CHANGED
|
@@ -4,5 +4,7 @@ import styled from "styled-components";
|
|
|
4
4
|
export var ViewStopButton = styled.button.withConfig({
|
|
5
5
|
displayName: "styled__ViewStopButton",
|
|
6
6
|
componentId: "sc-12v7ov3-0"
|
|
7
|
-
})(["background:none;border-bottom:none;
|
|
7
|
+
})(["background:none;border-bottom:none;", ";border-right:none;border-top:none;color:#008;font-family:inherit;padding-top:0;"], function (props) {
|
|
8
|
+
return props.stopId != null ? "border-left: 1px solid #000; margin-left: 5px;" : "border-left: none; padding-left: 0;";
|
|
9
|
+
});
|
|
8
10
|
//# sourceMappingURL=styled.js.map
|
package/esm/styled.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","names":["styled","ViewStopButton","button","withConfig","displayName","componentId"],"sources":["../src/styled.ts"],"sourcesContent":["import styled from \"styled-components\";\n\n/* eslint-disable-next-line import/prefer-default-export */\nexport const ViewStopButton = styled.button
|
|
1
|
+
{"version":3,"file":"styled.js","names":["styled","ViewStopButton","button","withConfig","displayName","componentId","props","stopId"],"sources":["../src/styled.ts"],"sourcesContent":["import styled from \"styled-components\";\n\n/* eslint-disable-next-line import/prefer-default-export */\nexport const ViewStopButton = styled.button<{ stopId?: string }>`\n background: none;\n border-bottom: none;\n ${props =>\n props.stopId != null\n ? \"border-left: 1px solid #000; margin-left: 5px;\"\n : \"border-left: none; padding-left: 0;\"};\n border-right: none;\n border-top: none;\n color: #008;\n font-family: inherit;\n padding-top: 0;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;;AAEtC;AACA,OAAO,IAAMC,cAAc,GAAGD,MAAM,CAACE,MAAM,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,gIAGvC,UAAAC,KAAK;EAAA,OACLA,KAAK,CAACC,MAAM,IAAI,IAAI,GAChB,gDAAgD,GAChD,qCAAqC;AAAA,EAM5C","ignoreList":[]}
|
package/esm/util.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import coreUtils from "@opentripplanner/core-utils";
|
|
2
|
-
|
|
3
2
|
// eslint-disable-next-line import/prefer-default-export
|
|
4
3
|
export function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
|
|
5
|
-
return function defaultGetEntityName(entity, configCompanies) {
|
|
4
|
+
return function defaultGetEntityName(entity, configCompanies, feedName) {
|
|
6
5
|
var _entity$networks;
|
|
7
6
|
// TODO: Stop generating this / passing it to the car string? Is it needed?
|
|
8
7
|
// In English we say "Car: " instead
|
|
@@ -40,6 +39,8 @@ export function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
|
|
|
40
39
|
}, {
|
|
41
40
|
name: stationName
|
|
42
41
|
});
|
|
42
|
+
} else if (feedName && "code" in entity) {
|
|
43
|
+
stationName = "".concat(stationName, " (").concat(feedName, " ").concat(entity.code, ")");
|
|
43
44
|
}
|
|
44
45
|
return stationName;
|
|
45
46
|
};
|
package/esm/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","names":["coreUtils","makeDefaultGetEntityName","intl","defaultEnglishMessages","defaultGetEntityName","entity","configCompanies","_entity$networks","stationNetworks","itinerary","getCompaniesLabelFromNetworks","networks","stationName","name","id","match","length","isFloatingBike","formatMessage","defaultMessage","description","isFloatingCar","company","isFloatingVehicle"],"sources":["../src/util.ts"],"sourcesContent":["import { Company, Station, Stop } from \"@opentripplanner/types\";\nimport { IntlShape } from \"react-intl\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\n// eslint-disable-next-line import/prefer-default-export\nexport function makeDefaultGetEntityName(\n intl: IntlShape,\n defaultEnglishMessages: { [key: string]: string }\n) {\n return function defaultGetEntityName(\n entity: Station | Stop,\n configCompanies: Company[]\n ): string | null {\n // TODO: Stop generating this / passing it to the car string? Is it needed?\n // In English we say \"Car: \" instead\n const stationNetworks =\n \"networks\" in entity &&\n (coreUtils.itinerary.getCompaniesLabelFromNetworks(\n entity?.networks || [],\n configCompanies\n ) ||\n entity?.networks?.[0]);\n let stationName: string | null = entity.name || entity.id;\n // If the station name or id is a giant UUID (with more than 3 \"-\" characters)\n // best not to show that at all. The company name will still be shown.\n // Also ignore \"Default Vehicle Type\"\n if (\n (stationName.match(/-/g) || []).length > 3 ||\n stationName === \"Default vehicle type\"\n ) {\n stationName = null;\n }\n\n if (\"isFloatingBike\" in entity && entity.isFloatingBike) {\n stationName = intl.formatMessage(\n {\n defaultMessage: defaultEnglishMessages[\"otpUi.MapPopup.floatingBike\"],\n description: \"Popup title for a free-floating bike\",\n id: \"otpUi.MapPopup.floatingBike\"\n },\n { name: stationName }\n );\n } else if (\"isFloatingCar\" in entity && entity.isFloatingCar) {\n stationName = intl.formatMessage(\n {\n defaultMessage: defaultEnglishMessages[\"otpUi.MapPopup.floatingCar\"],\n description: \"Popup title for a free-floating car\",\n id: \"otpUi.MapPopup.floatingCar\"\n },\n {\n company: stationNetworks,\n name: stationName\n }\n );\n } else if (\"isFloatingVehicle\" in entity && entity.isFloatingVehicle) {\n // assumes that all floating vehicles are E-scooters\n stationName = intl.formatMessage(\n {\n defaultMessage:\n defaultEnglishMessages[\"otpUi.MapPopup.floatingEScooter\"],\n description: \"Popup title for a free-floating e-scooter\",\n id: \"otpUi.MapPopup.floatingEScooter\"\n },\n { name: stationName }\n );\n }\n return stationName;\n };\n}\n"],"mappings":"AAEA,OAAOA,SAAS,MAAM,6BAA6B
|
|
1
|
+
{"version":3,"file":"util.js","names":["coreUtils","makeDefaultGetEntityName","intl","defaultEnglishMessages","defaultGetEntityName","entity","configCompanies","feedName","_entity$networks","stationNetworks","itinerary","getCompaniesLabelFromNetworks","networks","stationName","name","id","match","length","isFloatingBike","formatMessage","defaultMessage","description","isFloatingCar","company","isFloatingVehicle","concat","code"],"sources":["../src/util.ts"],"sourcesContent":["import { Agency, Company, Station, Stop } from \"@opentripplanner/types\";\nimport { IntlShape } from \"react-intl\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\nexport type StopIdAgencyMap = Record<string, Agency>;\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 feedName?: string\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 } else if (feedName && \"code\" in entity) {\n stationName = `${stationName} (${feedName} ${entity.code})`;\n }\n return stationName;\n };\n}\n"],"mappings":"AAEA,OAAOA,SAAS,MAAM,6BAA6B;AAInD;AACA,OAAO,SAASC,wBAAwBA,CACtCC,IAAe,EACfC,sBAAiD,EACjD;EACA,OAAO,SAASC,oBAAoBA,CAClCC,MAAsB,EACtBC,eAA0B,EAC1BC,QAAiB,EACF;IAAA,IAAAC,gBAAA;IACf;IACA;IACA,IAAMC,eAAe,GACnB,UAAU,IAAIJ,MAAM,KACnBL,SAAS,CAACU,SAAS,CAACC,6BAA6B,CAChD,CAAAN,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEO,QAAQ,KAAI,EAAE,EACtBN,eACF,CAAC,KACCD,MAAM,aAANA,MAAM,gBAAAG,gBAAA,GAANH,MAAM,CAAEO,QAAQ,cAAAJ,gBAAA,uBAAhBA,gBAAA,CAAmB,CAAC,CAAC,EAAC;IAC1B,IAAIK,WAA0B,GAAGR,MAAM,CAACS,IAAI,IAAIT,MAAM,CAACU,EAAE;IACzD;IACA;IACA;IACA,IACE,CAACF,WAAW,CAACG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAEC,MAAM,GAAG,CAAC,IAC1CJ,WAAW,KAAK,sBAAsB,EACtC;MACAA,WAAW,GAAG,IAAI;IACpB;IAEA,IAAI,gBAAgB,IAAIR,MAAM,IAAIA,MAAM,CAACa,cAAc,EAAE;MACvDL,WAAW,GAAGX,IAAI,CAACiB,aAAa,CAC9B;QACEC,cAAc,EAAEjB,sBAAsB,CAAC,6BAA6B,CAAC;QACrEkB,WAAW,EAAE,sCAAsC;QACnDN,EAAE,EAAE;MACN,CAAC,EACD;QAAED,IAAI,EAAED;MAAY,CACtB,CAAC;IACH,CAAC,MAAM,IAAI,eAAe,IAAIR,MAAM,IAAIA,MAAM,CAACiB,aAAa,EAAE;MAC5DT,WAAW,GAAGX,IAAI,CAACiB,aAAa,CAC9B;QACEC,cAAc,EAAEjB,sBAAsB,CAAC,4BAA4B,CAAC;QACpEkB,WAAW,EAAE,qCAAqC;QAClDN,EAAE,EAAE;MACN,CAAC,EACD;QACEQ,OAAO,EAAEd,eAAe;QACxBK,IAAI,EAAED;MACR,CACF,CAAC;IACH,CAAC,MAAM,IAAI,mBAAmB,IAAIR,MAAM,IAAIA,MAAM,CAACmB,iBAAiB,EAAE;MACpE;MACAX,WAAW,GAAGX,IAAI,CAACiB,aAAa,CAC9B;QACEC,cAAc,EACZjB,sBAAsB,CAAC,iCAAiC,CAAC;QAC3DkB,WAAW,EAAE,2CAA2C;QACxDN,EAAE,EAAE;MACN,CAAC,EACD;QAAED,IAAI,EAAED;MAAY,CACtB,CAAC;IACH,CAAC,MAAM,IAAIN,QAAQ,IAAI,MAAM,IAAIF,MAAM,EAAE;MACvCQ,WAAW,MAAAY,MAAA,CAAMZ,WAAW,QAAAY,MAAA,CAAKlB,QAAQ,OAAAkB,MAAA,CAAIpB,MAAM,CAACqB,IAAI,MAAG;IAC7D;IACA,OAAOb,WAAW;EACpB,CAAC;AACH","ignoreList":[]}
|
package/i18n/es.yml
CHANGED
|
@@ -4,7 +4,7 @@ otpUi:
|
|
|
4
4
|
availableDocks: "Estaciones de carga disponibles: {value}"
|
|
5
5
|
floatingBike: "Bicicleta flotante: {name}"
|
|
6
6
|
floatingCar: "Coche: {name}"
|
|
7
|
-
floatingEScooter:
|
|
7
|
+
floatingEScooter: 'Scooter eléctrico: {name}'
|
|
8
8
|
popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
|
|
9
9
|
stopId: Parada n°{stopId}
|
|
10
10
|
stopViewer: Visor de paradas
|
package/i18n/fr.yml
CHANGED
|
@@ -4,7 +4,7 @@ otpUi:
|
|
|
4
4
|
availableDocks: "Bornes disponibles : {value}"
|
|
5
5
|
floatingBike: "Vélo flottant : {name}"
|
|
6
6
|
floatingCar: "Voiture : {name}"
|
|
7
|
-
floatingEScooter:
|
|
7
|
+
floatingEScooter: 'Trottinette : {name}'
|
|
8
8
|
popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
|
|
9
9
|
stopId: Arrêt n°{stopId}
|
|
10
10
|
stopViewer: Info arrêt
|
package/i18n/ko.yml
CHANGED
|
@@ -4,7 +4,7 @@ otpUi:
|
|
|
4
4
|
availableDocks: "사용 가능한 도크: {value}"
|
|
5
5
|
floatingBike: "프리-플로팅 자전거: {name}"
|
|
6
6
|
floatingCar: "자동차: {name}"
|
|
7
|
-
floatingEScooter: 전동스쿠터:{name}
|
|
7
|
+
floatingEScooter: "전동스쿠터:{name}"
|
|
8
8
|
popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
|
|
9
9
|
stopId: "정류장 ID: {stopId}"
|
|
10
10
|
stopViewer: 정류장 뷰어
|
package/i18n/pl.yml
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
otpUi:
|
|
2
|
+
MapPopup:
|
|
3
|
+
popupTitle: '{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}'
|
|
4
|
+
availableBikes: 'Dostępne rowery: {value}'
|
|
5
|
+
availableDocks: 'Dostępne stanowiska: {value}'
|
|
6
|
+
floatingBike: 'Wolnostojące rowery: {name}'
|
|
7
|
+
floatingCar: 'Samochód: {name}'
|
|
8
|
+
floatingEScooter: 'Hulajnoga elektryczna: {name}'
|
|
9
|
+
stopId: 'Numer przystanku: {stopId}'
|
|
10
|
+
stopViewer: Podgląd przystanku
|
package/i18n/ta.yml
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
otpUi:
|
|
2
2
|
MapPopup:
|
|
3
|
-
availableBikes:
|
|
4
|
-
availableDocks:
|
|
5
|
-
floatingBike:
|
|
6
|
-
floatingCar:
|
|
7
|
-
floatingEScooter:
|
|
8
|
-
popupTitle:
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
stopId: "ஐடியை நிறுத்து: {stopId}"
|
|
3
|
+
availableBikes: 'கிடைக்கும் பைக்குகள்: {value}'
|
|
4
|
+
availableDocks: 'கிடைக்கும் கப்பல்துறைகள்: {value}'
|
|
5
|
+
floatingBike: 'இலவச-மிதக்கும் பைக்: {name}'
|
|
6
|
+
floatingCar: 'கார்: {name}'
|
|
7
|
+
floatingEScooter: 'மின்-ச்கூட்டர்: {name}'
|
|
8
|
+
popupTitle: '{ச்டேசனெட்ட்வொர்க், தேர்ந்தெடுக்கவும், பொய் {{name}} பிற {{stationNetwork}
|
|
9
|
+
{name}}}}'
|
|
10
|
+
stopId: 'ஐடியை நிறுத்து: {stopId}'
|
|
12
11
|
stopViewer: பார்வையாளரை நிறுத்துங்கள்
|
package/i18n/vi.yml
CHANGED
|
@@ -4,7 +4,7 @@ otpUi:
|
|
|
4
4
|
availableDocks: "Chỗ dựng xe đạp có sẵn: {value}"
|
|
5
5
|
floatingBike: "Xe đạp để tự do: {name}"
|
|
6
6
|
floatingCar: "Xe hơi: {name}"
|
|
7
|
-
floatingEScooter:
|
|
7
|
+
floatingEScooter: 'Xe tay ga điện: {name}'
|
|
8
8
|
popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
|
|
9
9
|
stopId: Điểm dừng số {stopId}
|
|
10
10
|
stopViewer: Xem điểm dừng
|
package/i18n/zh_Hans.yml
CHANGED
|
@@ -4,7 +4,7 @@ otpUi:
|
|
|
4
4
|
availableDocks: "可用的充电座: {value}"
|
|
5
5
|
floatingBike: "自由浮动的自行车: {name}"
|
|
6
6
|
floatingCar: "汽车: {name}"
|
|
7
|
-
floatingEScooter: 电动滑板车:{name}
|
|
7
|
+
floatingEScooter: "电动滑板车:{name}"
|
|
8
8
|
popupTitle: "{stationNetwork, select, false {{name}} other {{stationNetwork} {name}}}"
|
|
9
9
|
stopId: "车站 ID: {stopId}"
|
|
10
10
|
stopViewer: 车站查看器
|
package/lib/index.d.ts
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from "@opentripplanner/types";
|
|
3
|
+
import { type StopIdAgencyMap } from "./util";
|
|
3
4
|
export declare const defaultMessages: {
|
|
4
5
|
[key: string]: string;
|
|
5
6
|
};
|
|
7
|
+
export type Feed = {
|
|
8
|
+
feedId: string;
|
|
9
|
+
publisher: {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
6
13
|
type Entity = Stop | Station;
|
|
7
14
|
type Props = {
|
|
8
15
|
closePopup?: (arg?: any) => void;
|
|
9
16
|
configCompanies?: ConfiguredCompany[];
|
|
10
17
|
entity: Entity;
|
|
11
|
-
getEntityName?: (entity: Entity, configCompanies: Company[]) => string;
|
|
18
|
+
getEntityName?: (entity: Entity, configCompanies: Company[], feedName?: string) => string;
|
|
12
19
|
getEntityPrefix?: (entity: Entity) => JSX.Element;
|
|
20
|
+
feeds?: Feed[];
|
|
13
21
|
setLocation?: ({ location, locationType }: {
|
|
14
22
|
location: Location;
|
|
15
23
|
locationType: string;
|
|
@@ -19,6 +27,7 @@ type Props = {
|
|
|
19
27
|
/**
|
|
20
28
|
* Renders a map popup for a stop, scooter, or shared bike
|
|
21
29
|
*/
|
|
22
|
-
export declare function MapPopup({ closePopup, configCompanies, entity, getEntityName, getEntityPrefix, setLocation, setViewedStop }: Props): JSX.Element;
|
|
30
|
+
export declare function MapPopup({ closePopup, configCompanies, entity, getEntityName, getEntityPrefix, setLocation, setViewedStop, feeds, }: Props): JSX.Element;
|
|
23
31
|
export default MapPopup;
|
|
32
|
+
export { type StopIdAgencyMap };
|
|
24
33
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
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;AAWpH,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AAMxE,eAAO,MAAM,eAAe,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAoC,CAAC;AAE1F,MAAM,MAAM,IAAI,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH,CAAC;AAkEF,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAA;AAC5B,KAAK,KAAK,GAAG;IACX,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;IAChC,eAAe,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1F,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,GAAG,CAAC,OAAO,CAAA;IACjD,KAAK,CAAC,EAAE,IAAI,EAAE,CAAA;IACd,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,EACvB,UAAqB,EACrB,eAAe,EACf,MAAM,EACN,aAAa,EACb,eAAe,EACf,WAAW,EACX,aAAa,EACb,KAAK,GACN,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CA6DrB;AAED,eAAe,QAAQ,CAAC;AACxB,OAAO,EAAE,KAAK,eAAe,EAAE,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -67,7 +67,7 @@ const StopDetails = ({
|
|
|
67
67
|
id,
|
|
68
68
|
setViewedStop
|
|
69
69
|
}) => {
|
|
70
|
-
return /*#__PURE__*/_react.default.createElement(_baseMap.Styled.PopupRow, null, /*#__PURE__*/_react.default.createElement("strong", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
|
|
70
|
+
return /*#__PURE__*/_react.default.createElement(_baseMap.Styled.PopupRow, null, id && /*#__PURE__*/_react.default.createElement("strong", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
|
|
71
71
|
defaultMessage: defaultMessages["otpUi.MapPopup.stopId"],
|
|
72
72
|
description: "Displays the stop id",
|
|
73
73
|
id: "otpUi.MapPopup.stopId",
|
|
@@ -75,7 +75,8 @@ const StopDetails = ({
|
|
|
75
75
|
stopId: id
|
|
76
76
|
}
|
|
77
77
|
})), /*#__PURE__*/_react.default.createElement(_styled.ViewStopButton, {
|
|
78
|
-
onClick: setViewedStop
|
|
78
|
+
onClick: setViewedStop,
|
|
79
|
+
stopId: id
|
|
79
80
|
}, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
|
|
80
81
|
defaultMessage: defaultMessages["otpUi.MapPopup.stopViewer"],
|
|
81
82
|
description: "Text for link that opens the stop viewer",
|
|
@@ -96,19 +97,27 @@ function MapPopup({
|
|
|
96
97
|
getEntityName,
|
|
97
98
|
getEntityPrefix,
|
|
98
99
|
setLocation,
|
|
99
|
-
setViewedStop
|
|
100
|
+
setViewedStop,
|
|
101
|
+
feeds
|
|
100
102
|
}) {
|
|
101
103
|
var _entity$networks;
|
|
102
104
|
const intl = (0, _reactIntl.useIntl)();
|
|
103
105
|
if (!entity) return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
104
106
|
const getNameFunc = getEntityName || (0, _util.makeDefaultGetEntityName)(intl, defaultMessages);
|
|
105
|
-
|
|
107
|
+
|
|
108
|
+
// Find the feed name using the logic from generateLabel in otp.ts
|
|
109
|
+
let feedName;
|
|
110
|
+
if (feeds && entity.id) {
|
|
111
|
+
var _feed$publisher;
|
|
112
|
+
const feedId = entity.id.split(":")[0];
|
|
113
|
+
const feed = feeds.find(f => f.feedId === feedId);
|
|
114
|
+
feedName = feed === null || feed === void 0 || (_feed$publisher = feed.publisher) === null || _feed$publisher === void 0 ? void 0 : _feed$publisher.name;
|
|
115
|
+
}
|
|
116
|
+
const name = getNameFunc(entity, configCompanies, feedName);
|
|
106
117
|
const stationNetwork = "networks" in entity && (_coreUtils.default.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0 || (_entity$networks = entity.networks) === null || _entity$networks === void 0 ? void 0 : _entity$networks[0]));
|
|
107
118
|
const bikesAvailablePresent = entityIsStation(entity);
|
|
108
119
|
const entityIsStationHub = bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.bikesAvailable) !== undefined && !(entity !== null && entity !== void 0 && entity.isFloatingBike);
|
|
109
|
-
const stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code)
|
|
110
|
-
|
|
111
|
-
// Double quotes make the query invalid, so remove them from the id just in case
|
|
120
|
+
const stopId = !bikesAvailablePresent && (entity === null || entity === void 0 ? void 0 : entity.code);
|
|
112
121
|
const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, "")}-popup`;
|
|
113
122
|
return /*#__PURE__*/_react.default.createElement(_baseMap.Styled.MapOverlayPopup, null, /*#__PURE__*/_react.default.createElement(_buildingBlocks.FocusTrapWrapper, {
|
|
114
123
|
closePopup: closePopup,
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_fromToLocationPicker","_interopRequireDefault","_coreUtils","_buildingBlocks","_flat","_reactIntl","_baseMap","_styled","_enUS","_util","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","defaultMessages","exports","flatten","defaultEnglishMessages","generateLocation","entity","name","lon","entityLon","lat","entityLat","x","y","StationHubDetails","station","createElement","Styled","PopupRow","FormattedMessage","defaultMessage","description","id","values","value","bikesAvailable","spacesAvailable","StopDetails","setViewedStop","stopId","ViewStopButton","onClick","entityIsStation","MapPopup","closePopup","configCompanies","getEntityName","getEntityPrefix","setLocation","_entity$networks","intl","useIntl","Fragment","getNameFunc","makeDefaultGetEntityName","stationNetwork","coreUtils","itinerary","getCompaniesLabelFromNetworks","networks","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","split","encodeURIComponent","replace","MapOverlayPopup","FocusTrapWrapper","PopupTitle","useCallback","label","location","_default"],"sources":["../src/index.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport FromToLocationPicker from \"@opentripplanner/from-to-location-picker\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\n// eslint-disable-next-line prettier/prettier\nimport type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from \"@opentripplanner/types\";\n\nimport { FocusTrapWrapper } from \"@opentripplanner/building-blocks\";\nimport { flatten } from \"flat\";\nimport { FormattedMessage, useIntl } from \"react-intl\";\nimport { Styled } from \"@opentripplanner/base-map\";\n\nimport { ViewStopButton } from \"./styled\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\nimport { makeDefaultGetEntityName } from \"./util\";\n\n// HACK: We should flatten the messages loaded above because\n// the YAML loaders behave differently between webpack and our version of jest:\n// - the yaml loader for webpack returns a nested object,\n// - the yaml loader for jest returns messages with flattened ids.\nexport const defaultMessages: { [key: string]: string } = flatten(defaultEnglishMessages);\n\nconst generateLocation = (entity: Entity, name: string) => {\n // @ts-expect-error some of these values may be null, but that's ok\n const { lon: entityLon, lat: entityLat, x, y } = entity\n\n const lat = entityLat || y\n const lon = entityLon || x\n if (!lat || !lon) return null\n\n return { lat, lon, name };\n}\n\nconst StationHubDetails = ({ station }: { station: Station }) => {\n return (\n <Styled.PopupRow>\n <div>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.MapPopup.availableBikes\"]\n }\n description=\"Label text for the number of bikes available\"\n id=\"otpUi.MapPopup.availableBikes\"\n values={{ value: station.bikesAvailable }}\n />\n </div>\n <div>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.MapPopup.availableDocks\"]\n }\n description=\"Label text for the number of docks available\"\n id=\"otpUi.MapPopup.availableDocks\"\n values={{ value: station.spacesAvailable }}\n />\n </div>\n </Styled.PopupRow>\n )\n}\n\nconst StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {\n return (\n <Styled.PopupRow>\n <strong>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.stopId\"]}\n description=\"Displays the stop id\"\n id=\"otpUi.MapPopup.stopId\"\n values={{\n stopId: id\n }}\n />\n </strong>\n <ViewStopButton onClick={setViewedStop}>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.stopViewer\"]}\n description=\"Text for link that opens the stop viewer\"\n id=\"otpUi.MapPopup.stopViewer\"\n />\n </ViewStopButton>\n </Styled.PopupRow>\n )\n}\n\ntype Entity = Stop | Station\ntype Props = {\n closePopup?: (arg?: any) => void\n configCompanies?: ConfiguredCompany[];\n entity: Entity\n getEntityName?: (entity: Entity, configCompanies: Company[],) => string;\n getEntityPrefix?: (entity: Entity) => JSX.Element\n setLocation?: ({ location, locationType }: { location: Location, locationType: string }) => void;\n setViewedStop?: StopEventHandler;\n};\n\nfunction entityIsStation(entity: Entity): entity is Station {\n return \"bikesAvailable\" in entity\n}\n\n/**\n * Renders a map popup for a stop, scooter, or shared bike\n */\nexport function MapPopup({ closePopup = () => {}, configCompanies, entity, getEntityName, getEntityPrefix, setLocation, setViewedStop }: Props): JSX.Element {\n\n const intl = useIntl()\n if (!entity) return <></>\n\n const getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);\n const name = getNameFunc(entity, configCompanies);\n\n const stationNetwork = \"networks\" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks(entity?.networks || [], configCompanies) || entity?.networks?.[0]);\n\n const bikesAvailablePresent = entityIsStation(entity)\n const entityIsStationHub = bikesAvailablePresent && entity?.bikesAvailable !== undefined && !entity?.isFloatingBike;\n const stopId = !bikesAvailablePresent && entity?.code || entity.id.split(\":\")[1] || entity.id\n\n // Double quotes make the query invalid, so remove them from the id just in case\n const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, \"\")}-popup`\n\n return (\n <Styled.MapOverlayPopup>\n <FocusTrapWrapper closePopup={closePopup} id={id}>\n <Styled.PopupTitle>\n {getEntityPrefix && getEntityPrefix(entity)}\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.popupTitle\"]}\n description=\"Text for title of the popup, contains an optional company name\"\n id=\"otpUi.MapPopup.popupTitle\"\n values={{ name, stationNetwork }}\n />\n </Styled.PopupTitle>\n {/* render dock info if it is available */}\n {entityIsStationHub && <StationHubDetails station={entity} />}\n\n {/* render stop viewer link if available */}\n {setViewedStop && !bikesAvailablePresent && (\n <StopDetails\n id={stopId}\n setViewedStop={useCallback(() => setViewedStop(entity), [entity])}\n />\n )}\n\n {/* The \"Set as [from/to]\" ButtonGroup */}\n {setLocation && (\n <Styled.PopupRow>\n <FromToLocationPicker\n label\n location={generateLocation(entity, name)}\n setLocation={setLocation}\n />\n </Styled.PopupRow>\n )}\n </FocusTrapWrapper>\n \n </Styled.MapOverlayPopup>\n );\n}\n\nexport default MapPopup;"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAD,sBAAA,CAAAF,OAAA;AAKA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAEA,IAAAQ,OAAA,GAAAR,OAAA;AAGA,IAAAS,KAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,KAAA,GAAAV,OAAA;AAAkD,SAAAW,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAb,wBAAAa,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MA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MjC,aAAa,CAACtB,MAAM,CAAC,EAAE,CAACA,MAAM,CAAC;EAAE,CACnE,CACF,EAGAgC,WAAW,iBACVtE,MAAA,CAAAmB,OAAA,CAAA6B,aAAA,CAACvC,QAAA,CAAAwC,MAAM,CAACC,QAAQ,qBACdlD,MAAA,CAAAmB,OAAA,CAAA6B,aAAA,CAAC7C,qBAAA,CAAAgB,OAAoB;IACnB2E,KAAK;IACLC,QAAQ,EAAE1D,gBAAgB,CAACC,MAAM,EAAEC,IAAI,CAAE;IACzC+B,WAAW,EAAEA;EAAY,CAC1B,CACc,CAED,CAEI,CAAC;AAE7B;AAAC,IAAA0B,QAAA,GAAA9D,OAAA,CAAAf,OAAA,GAEc8C,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_fromToLocationPicker","_interopRequireDefault","_coreUtils","_buildingBlocks","_flat","_reactIntl","_baseMap","_styled","_enUS","_util","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","defaultMessages","exports","flatten","defaultEnglishMessages","generateLocation","entity","name","lon","entityLon","lat","entityLat","x","y","StationHubDetails","station","createElement","Styled","PopupRow","FormattedMessage","defaultMessage","description","id","values","value","bikesAvailable","spacesAvailable","StopDetails","setViewedStop","stopId","ViewStopButton","onClick","entityIsStation","MapPopup","closePopup","configCompanies","getEntityName","getEntityPrefix","setLocation","feeds","_entity$networks","intl","useIntl","Fragment","getNameFunc","makeDefaultGetEntityName","feedName","_feed$publisher","feedId","split","feed","find","f","publisher","stationNetwork","coreUtils","itinerary","getCompaniesLabelFromNetworks","networks","bikesAvailablePresent","entityIsStationHub","undefined","isFloatingBike","code","encodeURIComponent","replace","MapOverlayPopup","FocusTrapWrapper","PopupTitle","useCallback","label","location","_default"],"sources":["../src/index.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport FromToLocationPicker from \"@opentripplanner/from-to-location-picker\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\n// eslint-disable-next-line prettier/prettier\nimport type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from \"@opentripplanner/types\";\n\nimport { FocusTrapWrapper } from \"@opentripplanner/building-blocks\";\nimport { flatten } from \"flat\";\nimport { FormattedMessage, useIntl } from \"react-intl\";\nimport { Styled } from \"@opentripplanner/base-map\";\n\nimport { ViewStopButton } from \"./styled\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\nimport { makeDefaultGetEntityName, type StopIdAgencyMap } 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\nexport type Feed = {\n feedId: string;\n publisher: {\n name: string;\n };\n};\n\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 {id &&\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} stopId={id}> \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[], feedName?: string) => string;\n getEntityPrefix?: (entity: Entity) => JSX.Element\n feeds?: Feed[]\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({ \n closePopup = () => {}, \n configCompanies, \n entity, \n getEntityName, \n getEntityPrefix, \n setLocation, \n setViewedStop, \n feeds,\n}: Props): JSX.Element {\n\n const intl = useIntl()\n if (!entity) return <></>\n\n const getNameFunc = getEntityName || makeDefaultGetEntityName(intl, defaultMessages);\n \n // Find the feed name using the logic from generateLabel in otp.ts\n let feedName: string | undefined;\n if (feeds && entity.id) {\n const feedId = entity.id.split(\":\")[0];\n const feed = feeds.find(f => f.feedId === feedId);\n feedName = feed?.publisher?.name;\n }\n \n const name = getNameFunc(entity, configCompanies, feedName);\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;\n const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, \"\")}-popup`\n\n return (\n <Styled.MapOverlayPopup>\n <FocusTrapWrapper closePopup={closePopup} id={id}>\n <Styled.PopupTitle>\n {getEntityPrefix && getEntityPrefix(entity)}\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.MapPopup.popupTitle\"]}\n description=\"Text for title of the popup, contains an optional company name\"\n id=\"otpUi.MapPopup.popupTitle\"\n values={{ name, stationNetwork }}\n />\n </Styled.PopupTitle>\n {/* render dock info if it is available */}\n {entityIsStationHub && <StationHubDetails station={entity} />}\n\n {/* render stop viewer link if available */}\n {setViewedStop && !bikesAvailablePresent && (\n <StopDetails\n id={stopId}\n setViewedStop={useCallback(() => setViewedStop(entity), [entity])}\n />\n )}\n\n {/* The \"Set as [from/to]\" ButtonGroup */}\n {setLocation && (\n <Styled.PopupRow>\n <FromToLocationPicker\n label\n location={generateLocation(entity, name)}\n setLocation={setLocation}\n />\n </Styled.PopupRow>\n )}\n </FocusTrapWrapper>\n \n </Styled.MapOverlayPopup>\n );\n}\n\nexport default MapPopup;\nexport { type StopIdAgencyMap };"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAD,sBAAA,CAAAF,OAAA;AAKA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAEA,IAAAQ,OAAA,GAAAR,OAAA;AAGA,IAAAS,KAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,KAAA,GAAAV,OAAA;AAAwE,SAAAW,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAA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CAAAf,OAAA,GAEc8C,QAAQ","ignoreList":[]}
|
package/lib/styled.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export declare const ViewStopButton: import("styled-components").StyledComponent<"button", any, {
|
|
1
|
+
export declare const ViewStopButton: import("styled-components").StyledComponent<"button", any, {
|
|
2
|
+
stopId?: string;
|
|
3
|
+
}, never>;
|
|
2
4
|
//# sourceMappingURL=styled.d.ts.map
|
package/lib/styled.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc;aAA4B,MAAM;SAY5D,CAAC"}
|
package/lib/styled.js
CHANGED
|
@@ -10,5 +10,5 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
10
10
|
const ViewStopButton = exports.ViewStopButton = _styledComponents.default.button.withConfig({
|
|
11
11
|
displayName: "styled__ViewStopButton",
|
|
12
12
|
componentId: "sc-12v7ov3-0"
|
|
13
|
-
})(["background:none;border-bottom:none;
|
|
13
|
+
})(["background:none;border-bottom:none;", ";border-right:none;border-top:none;color:#008;font-family:inherit;padding-top:0;"], props => props.stopId != null ? "border-left: 1px solid #000; margin-left: 5px;" : "border-left: none; padding-left: 0;");
|
|
14
14
|
//# sourceMappingURL=styled.js.map
|
package/lib/styled.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","names":["_styledComponents","_interopRequireDefault","require","ViewStopButton","exports","styled","button","withConfig","displayName","componentId"],"sources":["../src/styled.ts"],"sourcesContent":["import styled from \"styled-components\";\n\n/* eslint-disable-next-line import/prefer-default-export */\nexport const ViewStopButton = styled.button
|
|
1
|
+
{"version":3,"file":"styled.js","names":["_styledComponents","_interopRequireDefault","require","ViewStopButton","exports","styled","button","withConfig","displayName","componentId","props","stopId"],"sources":["../src/styled.ts"],"sourcesContent":["import styled from \"styled-components\";\n\n/* eslint-disable-next-line import/prefer-default-export */\nexport const ViewStopButton = styled.button<{ stopId?: string }>`\n background: none;\n border-bottom: none;\n ${props =>\n props.stopId != null\n ? \"border-left: 1px solid #000; margin-left: 5px;\"\n : \"border-left: none; padding-left: 0;\"};\n border-right: none;\n border-top: none;\n color: #008;\n font-family: inherit;\n padding-top: 0;\n`;\n"],"mappings":";;;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA;AACO,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAGE,yBAAM,CAACC,MAAM,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,gIAGvCC,KAAK,IACLA,KAAK,CAACC,MAAM,IAAI,IAAI,GAChB,gDAAgD,GAChD,qCAAqC,CAM5C","ignoreList":[]}
|
package/lib/util.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Company, Station, Stop } from "@opentripplanner/types";
|
|
1
|
+
import { Agency, Company, Station, Stop } from "@opentripplanner/types";
|
|
2
2
|
import { IntlShape } from "react-intl";
|
|
3
|
+
export type StopIdAgencyMap = Record<string, Agency>;
|
|
3
4
|
export declare function makeDefaultGetEntityName(intl: IntlShape, defaultEnglishMessages: {
|
|
4
5
|
[key: string]: string;
|
|
5
|
-
}): (entity: Station | Stop, configCompanies: Company[]) => string | null;
|
|
6
|
+
}): (entity: Station | Stop, configCompanies: Company[], feedName?: string) => string | null;
|
|
6
7
|
//# sourceMappingURL=util.d.ts.map
|
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;
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAGrD,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,aACf,MAAM,KAChB,MAAM,GAAG,IAAI,CA0DjB"}
|
package/lib/util.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.makeDefaultGetEntityName = makeDefaultGetEntityName;
|
|
|
8
8
|
var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
|
|
9
9
|
// eslint-disable-next-line import/prefer-default-export
|
|
10
10
|
function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
|
|
11
|
-
return function defaultGetEntityName(entity, configCompanies) {
|
|
11
|
+
return function defaultGetEntityName(entity, configCompanies, feedName) {
|
|
12
12
|
var _entity$networks;
|
|
13
13
|
// TODO: Stop generating this / passing it to the car string? Is it needed?
|
|
14
14
|
// In English we say "Car: " instead
|
|
@@ -46,6 +46,8 @@ function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
|
|
|
46
46
|
}, {
|
|
47
47
|
name: stationName
|
|
48
48
|
});
|
|
49
|
+
} else if (feedName && "code" in entity) {
|
|
50
|
+
stationName = `${stationName} (${feedName} ${entity.code})`;
|
|
49
51
|
}
|
|
50
52
|
return stationName;
|
|
51
53
|
};
|
package/lib/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","names":["_coreUtils","_interopRequireDefault","require","makeDefaultGetEntityName","intl","defaultEnglishMessages","defaultGetEntityName","entity","configCompanies","_entity$networks","stationNetworks","coreUtils","itinerary","getCompaniesLabelFromNetworks","networks","stationName","name","id","match","length","isFloatingBike","formatMessage","defaultMessage","description","isFloatingCar","company","isFloatingVehicle"],"sources":["../src/util.ts"],"sourcesContent":["import { Company, Station, Stop } from \"@opentripplanner/types\";\nimport { IntlShape } from \"react-intl\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\n// eslint-disable-next-line import/prefer-default-export\nexport function makeDefaultGetEntityName(\n intl: IntlShape,\n defaultEnglishMessages: { [key: string]: string }\n) {\n return function defaultGetEntityName(\n entity: Station | Stop,\n configCompanies: Company[]\n ): string | null {\n // TODO: Stop generating this / passing it to the car string? Is it needed?\n // In English we say \"Car: \" instead\n const stationNetworks =\n \"networks\" in entity &&\n (coreUtils.itinerary.getCompaniesLabelFromNetworks(\n entity?.networks || [],\n configCompanies\n ) ||\n entity?.networks?.[0]);\n let stationName: string | null = entity.name || entity.id;\n // If the station name or id is a giant UUID (with more than 3 \"-\" characters)\n // best not to show that at all. The company name will still be shown.\n // Also ignore \"Default Vehicle Type\"\n if (\n (stationName.match(/-/g) || []).length > 3 ||\n stationName === \"Default vehicle type\"\n ) {\n stationName = null;\n }\n\n if (\"isFloatingBike\" in entity && entity.isFloatingBike) {\n stationName = intl.formatMessage(\n {\n defaultMessage: defaultEnglishMessages[\"otpUi.MapPopup.floatingBike\"],\n description: \"Popup title for a free-floating bike\",\n id: \"otpUi.MapPopup.floatingBike\"\n },\n { name: stationName }\n );\n } else if (\"isFloatingCar\" in entity && entity.isFloatingCar) {\n stationName = intl.formatMessage(\n {\n defaultMessage: defaultEnglishMessages[\"otpUi.MapPopup.floatingCar\"],\n description: \"Popup title for a free-floating car\",\n id: \"otpUi.MapPopup.floatingCar\"\n },\n {\n company: stationNetworks,\n name: stationName\n }\n );\n } else if (\"isFloatingVehicle\" in entity && entity.isFloatingVehicle) {\n // assumes that all floating vehicles are E-scooters\n stationName = intl.formatMessage(\n {\n defaultMessage:\n defaultEnglishMessages[\"otpUi.MapPopup.floatingEScooter\"],\n description: \"Popup title for a free-floating e-scooter\",\n id: \"otpUi.MapPopup.floatingEScooter\"\n },\n { name: stationName }\n );\n }\n return stationName;\n };\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;
|
|
1
|
+
{"version":3,"file":"util.js","names":["_coreUtils","_interopRequireDefault","require","makeDefaultGetEntityName","intl","defaultEnglishMessages","defaultGetEntityName","entity","configCompanies","feedName","_entity$networks","stationNetworks","coreUtils","itinerary","getCompaniesLabelFromNetworks","networks","stationName","name","id","match","length","isFloatingBike","formatMessage","defaultMessage","description","isFloatingCar","company","isFloatingVehicle","code"],"sources":["../src/util.ts"],"sourcesContent":["import { Agency, Company, Station, Stop } from \"@opentripplanner/types\";\nimport { IntlShape } from \"react-intl\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\nexport type StopIdAgencyMap = Record<string, Agency>;\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 feedName?: string\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 } else if (feedName && \"code\" in entity) {\n stationName = `${stationName} (${feedName} ${entity.code})`;\n }\n return stationName;\n };\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA;AACO,SAASC,wBAAwBA,CACtCC,IAAe,EACfC,sBAAiD,EACjD;EACA,OAAO,SAASC,oBAAoBA,CAClCC,MAAsB,EACtBC,eAA0B,EAC1BC,QAAiB,EACF;IAAA,IAAAC,gBAAA;IACf;IACA;IACA,MAAMC,eAAe,GACnB,UAAU,IAAIJ,MAAM,KACnBK,kBAAS,CAACC,SAAS,CAACC,6BAA6B,CAChD,CAAAP,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEQ,QAAQ,KAAI,EAAE,EACtBP,eACF,CAAC,KACCD,MAAM,aAANA,MAAM,gBAAAG,gBAAA,GAANH,MAAM,CAAEQ,QAAQ,cAAAL,gBAAA,uBAAhBA,gBAAA,CAAmB,CAAC,CAAC,EAAC;IAC1B,IAAIM,WAA0B,GAAGT,MAAM,CAACU,IAAI,IAAIV,MAAM,CAACW,EAAE;IACzD;IACA;IACA;IACA,IACE,CAACF,WAAW,CAACG,KAAK,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opentripplanner/map-popup",
|
|
3
|
-
"version": "6.1.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "A component for displaying map popup contents",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"private": false,
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"flat": "^5.0.2",
|
|
15
|
-
"@opentripplanner/
|
|
16
|
-
"@opentripplanner/
|
|
17
|
-
"@opentripplanner/
|
|
18
|
-
"@opentripplanner/
|
|
15
|
+
"@opentripplanner/building-blocks": "3.0.1",
|
|
16
|
+
"@opentripplanner/core-utils": "13.0.1",
|
|
17
|
+
"@opentripplanner/from-to-location-picker": "4.0.1",
|
|
18
|
+
"@opentripplanner/base-map": "5.2.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@opentripplanner/types": "
|
|
21
|
+
"@opentripplanner/types": "6.5.3"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "^18.2.0",
|