@opentripplanner/map-popup 6.1.0 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/styled.js CHANGED
@@ -1,14 +1,21 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
7
6
  exports.ViewStopButton = void 0;
8
- var _styledComponents = _interopRequireDefault(require("styled-components"));
7
+ const styled_components_1 = __importDefault(require("styled-components"));
9
8
  /* eslint-disable-next-line import/prefer-default-export */
10
- const ViewStopButton = exports.ViewStopButton = _styledComponents.default.button.withConfig({
11
- displayName: "styled__ViewStopButton",
12
- componentId: "sc-12v7ov3-0"
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;");
9
+ exports.ViewStopButton = styled_components_1.default.button `
10
+ background: none;
11
+ border-bottom: none;
12
+ ${props => props.stopId != null
13
+ ? "border-left: 1px solid #000; margin-left: 5px;"
14
+ : "border-left: none; padding-left: 0;"};
15
+ border-right: none;
16
+ border-top: none;
17
+ color: #008;
18
+ font-family: inherit;
19
+ padding-top: 0;
20
+ `;
14
21
  //# 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","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":[]}
1
+ {"version":3,"file":"styled.js","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":";;;;;;AAAA,0EAAuC;AAEvC,2DAA2D;AAC9C,QAAA,cAAc,GAAG,2BAAM,CAAC,MAAM,CAAqB;;;IAG5D,KAAK,CAAC,EAAE,CACR,KAAK,CAAC,MAAM,IAAI,IAAI;IAClB,CAAC,CAAC,gDAAgD;IAClD,CAAC,CAAC,qCAAqC;;;;;;CAM5C,CAAC"}
package/lib/util.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { Agency, Company, Station, Stop } from "@opentripplanner/types";
1
+ import { Agency, Company, Station, Stop, TileLayerStation } from "@opentripplanner/types";
2
2
  import { IntlShape } from "react-intl";
3
3
  export type StopIdAgencyMap = Record<string, Agency>;
4
+ export type Entity = Station | Stop | TileLayerStation;
5
+ export declare function getNetwork(entity: Entity, configCompanies: Company[]): string;
4
6
  export declare function makeDefaultGetEntityName(intl: IntlShape, defaultEnglishMessages: {
5
7
  [key: string]: string;
6
- }): (entity: Station | Stop, configCompanies: Company[], feedName?: string) => string | null;
8
+ }): (entity: Entity, configCompanies: Company[], feedName?: string, includeParenthetical?: boolean) => string | null;
7
9
  //# 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,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"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,IAAI,EACJ,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACrD,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,gBAAgB,CAAC;AAEvD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,MAAM,CAS7E;AAGD,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,SAAS,EACf,sBAAsB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,YAGvC,MAAM,mBACG,OAAO,EAAE,aACf,MAAM,qCAEhB,MAAM,GAAG,IAAI,CAoDjB"}
package/lib/util.js CHANGED
@@ -1,55 +1,60 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.makeDefaultGetEntityName = makeDefaultGetEntityName;
8
- var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.makeDefaultGetEntityName = exports.getNetwork = void 0;
7
+ const core_utils_1 = __importDefault(require("@opentripplanner/core-utils"));
8
+ function getNetwork(entity, configCompanies) {
9
+ return ("network" in entity &&
10
+ (core_utils_1.default.itinerary.getCompaniesLabelFromNetworks([entity.network], configCompanies) ||
11
+ entity.network));
12
+ }
13
+ exports.getNetwork = getNetwork;
9
14
  // eslint-disable-next-line import/prefer-default-export
10
15
  function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
11
- return function defaultGetEntityName(entity, configCompanies, feedName) {
12
- var _entity$networks;
13
- // TODO: Stop generating this / passing it to the car string? Is it needed?
14
- // In English we say "Car: " instead
15
- const stationNetworks = "networks" in entity && (_coreUtils.default.itinerary.getCompaniesLabelFromNetworks((entity === null || entity === void 0 ? void 0 : entity.networks) || [], configCompanies) || (entity === null || entity === void 0 || (_entity$networks = entity.networks) === null || _entity$networks === void 0 ? void 0 : _entity$networks[0]));
16
- let stationName = entity.name || entity.id;
17
- // If the station name or id is a giant UUID (with more than 3 "-" characters)
18
- // best not to show that at all. The company name will still be shown.
19
- // Also ignore "Default Vehicle Type"
20
- if ((stationName.match(/-/g) || []).length > 3 || stationName === "Default vehicle type") {
21
- stationName = null;
22
- }
23
- if ("isFloatingBike" in entity && entity.isFloatingBike) {
24
- stationName = intl.formatMessage({
25
- defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingBike"],
26
- description: "Popup title for a free-floating bike",
27
- id: "otpUi.MapPopup.floatingBike"
28
- }, {
29
- name: stationName
30
- });
31
- } else if ("isFloatingCar" in entity && entity.isFloatingCar) {
32
- stationName = intl.formatMessage({
33
- defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingCar"],
34
- description: "Popup title for a free-floating car",
35
- id: "otpUi.MapPopup.floatingCar"
36
- }, {
37
- company: stationNetworks,
38
- name: stationName
39
- });
40
- } else if ("isFloatingVehicle" in entity && entity.isFloatingVehicle) {
41
- // assumes that all floating vehicles are E-scooters
42
- stationName = intl.formatMessage({
43
- defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingEScooter"],
44
- description: "Popup title for a free-floating e-scooter",
45
- id: "otpUi.MapPopup.floatingEScooter"
46
- }, {
47
- name: stationName
48
- });
49
- } else if (feedName && "code" in entity) {
50
- stationName = `${stationName} (${feedName} ${entity.code})`;
51
- }
52
- return stationName;
53
- };
16
+ return function defaultGetEntityName(entity, configCompanies, feedName, includeParenthetical = true) {
17
+ let stationName = entity.name || entity.id;
18
+ // If the station name or id is a giant UUID (with more than 3 "-" characters)
19
+ // best not to show that at all. The company name will still be shown.
20
+ // Also ignore "Default Vehicle Type"
21
+ if ((stationName.match(/-/g) || []).length > 3 ||
22
+ stationName === "Default vehicle type") {
23
+ stationName = null;
24
+ }
25
+ if ("isFloatingBike" in entity && entity.isFloatingBike) {
26
+ stationName = intl.formatMessage({
27
+ defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingBike"],
28
+ description: "Popup title for a free-floating bike",
29
+ id: "otpUi.MapPopup.floatingBike"
30
+ }, { name: stationName });
31
+ }
32
+ else if ("isFloatingCar" in entity && entity.isFloatingCar) {
33
+ // TODO: Stop generating this / passing it to the car string? Is it needed?
34
+ // In English we say "Car: " instead
35
+ const stationNetwork = getNetwork(entity, configCompanies);
36
+ stationName = intl.formatMessage({
37
+ defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingCar"],
38
+ description: "Popup title for a free-floating car",
39
+ id: "otpUi.MapPopup.floatingCar"
40
+ }, {
41
+ company: stationNetwork,
42
+ name: stationName
43
+ });
44
+ }
45
+ else if ("isFloatingVehicle" in entity && entity.isFloatingVehicle) {
46
+ // assumes that all floating vehicles are E-scooters
47
+ stationName = intl.formatMessage({
48
+ defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingEScooter"],
49
+ description: "Popup title for a free-floating e-scooter",
50
+ id: "otpUi.MapPopup.floatingEScooter"
51
+ }, { name: stationName });
52
+ }
53
+ else if (includeParenthetical && feedName && "code" in entity) {
54
+ stationName = `${stationName} (${feedName} ${entity.code})`;
55
+ }
56
+ return stationName;
57
+ };
54
58
  }
59
+ exports.makeDefaultGetEntityName = makeDefaultGetEntityName;
55
60
  //# sourceMappingURL=util.js.map
package/lib/util.js.map CHANGED
@@ -1 +1 @@
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,g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C,MAAM,EAAE,eAAe,CAAC,CAAC;YAC3D,WAAW,GAAG,IAAI,CAAC,aAAa,CAC9B;gBACE,cAAc,EAAE,sBAAsB,CAAC,4BAA4B,CAAC;gBACpE,WAAW,EAAE,qCAAqC;gBAClD,EAAE,EAAE,4BAA4B;aACjC,EACD;gBACE,OAAO,EAAE,cAAc;gBACvB,IAAI,EAAE,WAAW;aAClB,CACF,CAAC;SACH;aAAM,IAAI,mBAAmB,IAAI,MAAM,IAAI,MAAM,CAAC,iBAAiB,EAAE;YACpE,oDAAoD;YACpD,WAAW,GAAG,IAAI,CAAC,aAAa,CAC9B;gBACE,cAAc,EACZ,sBAAsB,CAAC,iCAAiC,CAAC;gBAC3D,WAAW,EAAE,2CAA2C;gBACxD,EAAE,EAAE,iCAAiC;aACtC,EACD,EAAE,IAAI,EAAE,WAAW,EAAE,CACtB,CAAC;SACH;aAAM,IAAI,oBAAoB,IAAI,QAAQ,IAAI,MAAM,IAAI,MAAM,EAAE;YAC/D,WAAW,GAAG,GAAG,WAAW,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC;SAC7D;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC;AA7DD,4DA6DC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentripplanner/map-popup",
3
- "version": "6.1.0",
3
+ "version": "7.0.1",
4
4
  "description": "A component for displaying map popup contents",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -13,12 +13,12 @@
13
13
  "dependencies": {
14
14
  "flat": "^5.0.2",
15
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"
16
+ "@opentripplanner/base-map": "6.0.0",
17
+ "@opentripplanner/core-utils": "14.0.0",
18
+ "@opentripplanner/from-to-location-picker": "4.0.1"
19
19
  },
20
20
  "devDependencies": {
21
- "@opentripplanner/types": "6.5.3"
21
+ "@opentripplanner/types": "8.0.0"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "^18.2.0",
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
- import { action } from "@storybook/addon-actions";
2
+ import { action } from "storybook/actions";
3
3
  import styled from "styled-components";
4
4
  import { Station, Stop } from "@opentripplanner/types";
5
5
  import { IntlProvider } from "react-intl";
6
- import { Meta } from "@storybook/react";
6
+ import { Meta } from "@storybook/react-vite";
7
7
  import MapPopupContents, { Feed } from "./index";
8
8
 
9
9
  // HOC to wrap components with IntlProvider
@@ -72,34 +72,34 @@ const STATION = {
72
72
  "stroke-width": 2,
73
73
  allowDropoff: true,
74
74
  allowPickup: true,
75
- bikesAvailable: 6,
76
75
  color: "#f00",
77
76
  id: '"hub_1580"',
78
77
  isCarStation: false,
79
78
  isFloatingBike: false,
79
+ lat: 45.5219604810172,
80
+ lon: -122.6896771788597,
80
81
  name: "SW Morrison at 18th",
81
- networks: ["BIKETOWN"],
82
+ network: "BIKETOWN",
82
83
  realTimeData: true,
83
84
  spacesAvailable: 11,
84
- x: -122.6896771788597,
85
- y: 45.5219604810172
85
+ vehiclesAvailable: 6
86
86
  };
87
87
 
88
88
  const FLOATING_VEHICLE = {
89
89
  "stroke-width": 1,
90
90
  allowDropoff: false,
91
91
  allowPickup: true,
92
- bikesAvailable: 1,
93
92
  color: "#f00",
94
93
  id: '"bike_6861"',
95
94
  isCarStation: false,
96
95
  isFloatingBike: true,
96
+ lat: 45.525486666666666,
97
+ lon: -122.70486,
97
98
  name: "0541",
98
- networks: ["BIKETOWN"],
99
+ network: "BIKETOWN",
99
100
  realTimeData: true,
100
101
  spacesAvailable: 0,
101
- x: -122.70486,
102
- y: 45.525486666666666
102
+ vehiclesAvailable: 1
103
103
  };
104
104
 
105
105
  const FLOATING_CAR = {
@@ -110,12 +110,12 @@ const FLOATING_CAR = {
110
110
  id: "car_6861",
111
111
  isCarStation: false,
112
112
  isFloatingCar: true,
113
+ lat: 52.52,
114
+ lon: 13.405,
113
115
  name: "0541",
114
- networks: ["MILES"], // https://miles-mobility.com
116
+ network: "MILES", // https://miles-mobility.com
115
117
  realTimeData: true,
116
- spacesAvailable: 0,
117
- x: 13.405,
118
- y: 52.52
118
+ spacesAvailable: 0
119
119
  };
120
120
 
121
121
  const getEntityPrefixExample = (entity: Stop | Station) => {
@@ -265,7 +265,7 @@ exports[`Map Popup StopEntityNoStopCode smoke-test 1`] = `
265
265
  W Burnside &amp; SW 2nd
266
266
  </header>
267
267
  <p class="styled__PopupRow-sc-12kjso7-2 ckOOWr">
268
- <button class="styled__ViewStopButton-sc-12v7ov3-0 bbtcwi">
268
+ <button class="styled__ViewStopButton-sc-12v7ov3-0 hXaHvR">
269
269
  Stop Viewer
270
270
  </button>
271
271
  </p>
@@ -392,11 +392,11 @@ exports[`Map Popup StopEntityWithFeedName smoke-test 1`] = `
392
392
  role="presentation"
393
393
  >
394
394
  <header class="styled__PopupTitle-sc-12kjso7-3 jRNaQh">
395
- W Burnside &amp; SW 2nd (TriMet 9526)
395
+ W Burnside &amp; SW 2nd
396
396
  </header>
397
397
  <p class="styled__PopupRow-sc-12kjso7-2 ckOOWr">
398
398
  <strong>
399
- Stop ID: 9526
399
+ Stop ID: TriMet 9526
400
400
  </strong>
401
401
  <button class="styled__ViewStopButton-sc-12v7ov3-0 hXaHvR">
402
402
  Stop Viewer
package/src/index.tsx CHANGED
@@ -1,20 +1,26 @@
1
1
  import React, { useCallback } from "react";
2
2
  import FromToLocationPicker from "@opentripplanner/from-to-location-picker";
3
- import coreUtils from "@opentripplanner/core-utils";
4
3
 
5
4
  // eslint-disable-next-line prettier/prettier
6
- import type { Company, ConfiguredCompany, Location, Station, Stop, StopEventHandler } from "@opentripplanner/types";
5
+ import type {
6
+ Company,
7
+ ConfiguredCompany,
8
+ Location,
9
+ Stop,
10
+ StopEventHandler,
11
+ TileLayerStation
12
+ } from "@opentripplanner/types";
7
13
 
8
14
  import { FocusTrapWrapper } from "@opentripplanner/building-blocks";
9
15
  import { flatten } from "flat";
10
16
  import { FormattedMessage, useIntl } from "react-intl";
11
17
  import { Styled } from "@opentripplanner/base-map";
12
18
 
19
+ import { Entity, getNetwork, makeDefaultGetEntityName, type StopIdAgencyMap } from "./util";
13
20
  import { ViewStopButton } from "./styled";
14
21
 
15
22
  // Load the default messages.
16
23
  import defaultEnglishMessages from "../i18n/en-US.yml";
17
- import { makeDefaultGetEntityName, type StopIdAgencyMap } from "./util";
18
24
 
19
25
  // HACK: We should flatten the messages loaded above because
20
26
  // the YAML loaders behave differently between webpack and our version of jest:
@@ -41,7 +47,7 @@ const generateLocation = (entity: Entity, name: string) => {
41
47
  return { lat, lon, name };
42
48
  }
43
49
 
44
- const StationHubDetails = ({ station }: { station: Station }) => {
50
+ const StationHubDetails = ({ station }: { station: TileLayerStation }) => {
45
51
  return (
46
52
  <Styled.PopupRow>
47
53
  <div>
@@ -51,7 +57,7 @@ const StationHubDetails = ({ station }: { station: Station }) => {
51
57
  }
52
58
  description="Label text for the number of bikes available"
53
59
  id="otpUi.MapPopup.availableBikes"
54
- values={{ value: station.bikesAvailable }}
60
+ values={{ value: station.vehiclesAvailable }}
55
61
  />
56
62
  </div>
57
63
  <div>
@@ -68,7 +74,7 @@ const StationHubDetails = ({ station }: { station: Station }) => {
68
74
  )
69
75
  }
70
76
 
71
- const StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {
77
+ const StopDetails = ({ id, feedName, setViewedStop }: { id: string, feedName?: string, setViewedStop: () => void; }) => {
72
78
  return (
73
79
  <Styled.PopupRow>
74
80
  {id &&
@@ -78,6 +84,7 @@ const StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => v
78
84
  description="Displays the stop id"
79
85
  id="otpUi.MapPopup.stopId"
80
86
  values={{
87
+ feedName,
81
88
  stopId: id
82
89
  }}
83
90
  />
@@ -93,20 +100,19 @@ const StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => v
93
100
  )
94
101
  }
95
102
 
96
- type Entity = Stop | Station
97
103
  type Props = {
98
- closePopup?: (arg?: any) => void
104
+ closePopup?: (arg?: boolean) => void
99
105
  configCompanies?: ConfiguredCompany[];
100
106
  entity: Entity
101
- getEntityName?: (entity: Entity, configCompanies: Company[], feedName?: string) => string;
107
+ getEntityName?: (entity: Entity, configCompanies: Company[], feedName?: string, includeParenthetical?: boolean) => string;
102
108
  getEntityPrefix?: (entity: Entity) => JSX.Element
103
109
  feeds?: Feed[]
104
110
  setLocation?: ({ location, locationType }: { location: Location, locationType: string }) => void;
105
111
  setViewedStop?: StopEventHandler;
106
112
  };
107
113
 
108
- function entityIsStation(entity: Entity): entity is Station {
109
- return "bikesAvailable" in entity
114
+ function entityIsStation(entity: Entity): entity is TileLayerStation {
115
+ return "vehiclesAvailable" in entity
110
116
  }
111
117
 
112
118
  /**
@@ -137,12 +143,13 @@ export function MapPopup({
137
143
  }
138
144
 
139
145
  const name = getNameFunc(entity, configCompanies, feedName);
146
+ const titleName = getNameFunc(entity, configCompanies, feedName, false);
140
147
 
141
- const stationNetwork = "networks" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks(entity?.networks || [], configCompanies) || entity?.networks?.[0]);
148
+ const stationNetwork = getNetwork(entity, configCompanies);
142
149
 
143
150
  const bikesAvailablePresent = entityIsStation(entity)
144
- const entityIsStationHub = bikesAvailablePresent && entity?.bikesAvailable !== undefined && !entity?.isFloatingBike;
145
- const stopId = !bikesAvailablePresent && entity?.code;
151
+ const entityIsStationHub = bikesAvailablePresent && entity.vehiclesAvailable !== undefined && !entity.isFloatingBike;
152
+ const stopId = !bikesAvailablePresent && "code" in entity && entity.code;
146
153
  const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, "")}-popup`
147
154
 
148
155
  return (
@@ -154,7 +161,7 @@ export function MapPopup({
154
161
  defaultMessage={defaultMessages["otpUi.MapPopup.popupTitle"]}
155
162
  description="Text for title of the popup, contains an optional company name"
156
163
  id="otpUi.MapPopup.popupTitle"
157
- values={{ name, stationNetwork }}
164
+ values={{ name: titleName, stationNetwork }}
158
165
  />
159
166
  </Styled.PopupTitle>
160
167
  {/* render dock info if it is available */}
@@ -164,7 +171,8 @@ export function MapPopup({
164
171
  {setViewedStop && !bikesAvailablePresent && (
165
172
  <StopDetails
166
173
  id={stopId}
167
- setViewedStop={useCallback(() => setViewedStop(entity), [entity])}
174
+ feedName={feedName}
175
+ setViewedStop={useCallback(() => setViewedStop(entity as Stop), [entity])}
168
176
  />
169
177
  )}
170
178
 
package/src/util.ts CHANGED
@@ -1,8 +1,26 @@
1
- import { Agency, Company, Station, Stop } from "@opentripplanner/types";
1
+ import {
2
+ Agency,
3
+ Company,
4
+ Station,
5
+ Stop,
6
+ TileLayerStation
7
+ } from "@opentripplanner/types";
2
8
  import { IntlShape } from "react-intl";
3
9
  import coreUtils from "@opentripplanner/core-utils";
4
10
 
5
11
  export type StopIdAgencyMap = Record<string, Agency>;
12
+ export type Entity = Station | Stop | TileLayerStation;
13
+
14
+ export function getNetwork(entity: Entity, configCompanies: Company[]): string {
15
+ return (
16
+ "network" in entity &&
17
+ (coreUtils.itinerary.getCompaniesLabelFromNetworks(
18
+ [entity.network],
19
+ configCompanies
20
+ ) ||
21
+ entity.network)
22
+ );
23
+ }
6
24
 
7
25
  // eslint-disable-next-line import/prefer-default-export
8
26
  export function makeDefaultGetEntityName(
@@ -10,19 +28,11 @@ export function makeDefaultGetEntityName(
10
28
  defaultEnglishMessages: { [key: string]: string }
11
29
  ) {
12
30
  return function defaultGetEntityName(
13
- entity: Station | Stop,
31
+ entity: Entity,
14
32
  configCompanies: Company[],
15
- feedName?: string
33
+ feedName?: string,
34
+ includeParenthetical = true
16
35
  ): string | null {
17
- // TODO: Stop generating this / passing it to the car string? Is it needed?
18
- // In English we say "Car: " instead
19
- const stationNetworks =
20
- "networks" in entity &&
21
- (coreUtils.itinerary.getCompaniesLabelFromNetworks(
22
- entity?.networks || [],
23
- configCompanies
24
- ) ||
25
- entity?.networks?.[0]);
26
36
  let stationName: string | null = entity.name || entity.id;
27
37
  // If the station name or id is a giant UUID (with more than 3 "-" characters)
28
38
  // best not to show that at all. The company name will still be shown.
@@ -44,6 +54,9 @@ export function makeDefaultGetEntityName(
44
54
  { name: stationName }
45
55
  );
46
56
  } else if ("isFloatingCar" in entity && entity.isFloatingCar) {
57
+ // TODO: Stop generating this / passing it to the car string? Is it needed?
58
+ // In English we say "Car: " instead
59
+ const stationNetwork = getNetwork(entity, configCompanies);
47
60
  stationName = intl.formatMessage(
48
61
  {
49
62
  defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingCar"],
@@ -51,7 +64,7 @@ export function makeDefaultGetEntityName(
51
64
  id: "otpUi.MapPopup.floatingCar"
52
65
  },
53
66
  {
54
- company: stationNetworks,
67
+ company: stationNetwork,
55
68
  name: stationName
56
69
  }
57
70
  );
@@ -66,7 +79,7 @@ export function makeDefaultGetEntityName(
66
79
  },
67
80
  { name: stationName }
68
81
  );
69
- } else if (feedName && "code" in entity) {
82
+ } else if (includeParenthetical && feedName && "code" in entity) {
70
83
  stationName = `${stationName} (${feedName} ${entity.code})`;
71
84
  }
72
85
  return stationName;