@opentripplanner/map-popup 7.0.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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,9 +1,10 @@
1
- import { Agency, Company, Station, Stop, TileLayerStation } from "@opentripplanner/types";
1
+ import { RentalVehicle, VehicleRentalStation } from "@opentripplanner/types/otp2";
2
+ import { Agency, Company, Stop } from "@opentripplanner/types";
2
3
  import { IntlShape } from "react-intl";
3
4
  export type StopIdAgencyMap = Record<string, Agency>;
4
- export type Entity = Station | Stop | TileLayerStation;
5
+ export type Entity = VehicleRentalStation | Stop | RentalVehicle;
5
6
  export declare function getNetwork(entity: Entity, configCompanies: Company[]): string;
6
7
  export declare function makeDefaultGetEntityName(intl: IntlShape, defaultEnglishMessages: {
7
8
  [key: string]: string;
8
- }): (entity: Entity, configCompanies: Company[], feedName?: string) => string | null;
9
+ }): (entity: Entity, configCompanies: Company[], feedName?: string, includeParenthetical?: boolean) => string | null;
9
10
  //# 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,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,KAChB,MAAM,GAAG,IAAI,CAoDjB"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACrD,MAAM,MAAM,MAAM,GAAG,oBAAoB,GAAG,IAAI,GAAG,aAAa,CAAC;AAEjE,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,CA8DjB"}
package/lib/util.js CHANGED
@@ -1,59 +1,65 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.getNetwork = getNetwork;
8
- exports.makeDefaultGetEntityName = makeDefaultGetEntityName;
9
- 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"));
10
8
  function getNetwork(entity, configCompanies) {
11
- return "network" in entity && (_coreUtils.default.itinerary.getCompaniesLabelFromNetworks([entity.network] || [], configCompanies) || entity.network);
9
+ return ("rentalNetwork" in entity &&
10
+ (core_utils_1.default.itinerary.getCompaniesLabelFromNetworks(entity.rentalNetwork.networkId, configCompanies) ||
11
+ entity.rentalNetwork.networkId));
12
12
  }
13
-
13
+ exports.getNetwork = getNetwork;
14
14
  // eslint-disable-next-line import/prefer-default-export
15
15
  function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
16
- return function defaultGetEntityName(entity, configCompanies, feedName) {
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 || stationName === "Default vehicle type") {
22
- stationName = null;
23
- }
24
- if ("isFloatingBike" in entity && entity.isFloatingBike) {
25
- stationName = intl.formatMessage({
26
- defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingBike"],
27
- description: "Popup title for a free-floating bike",
28
- id: "otpUi.MapPopup.floatingBike"
29
- }, {
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
- } else if ("isFloatingVehicle" in entity && entity.isFloatingVehicle) {
45
- // assumes that all floating vehicles are E-scooters
46
- stationName = intl.formatMessage({
47
- defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingEScooter"],
48
- description: "Popup title for a free-floating e-scooter",
49
- id: "otpUi.MapPopup.floatingEScooter"
50
- }, {
51
- name: stationName
52
- });
53
- } else if (feedName && "code" in entity) {
54
- stationName = `${stationName} (${feedName} ${entity.code})`;
55
- }
56
- return stationName;
57
- };
16
+ return function defaultGetEntityName(entity, configCompanies, feedName, includeParenthetical = true) {
17
+ var _a, _b, _c;
18
+ let stationName = entity.name || entity.id;
19
+ // If the station name or id is a giant UUID (with more than 3 "-" characters)
20
+ // best not to show that at all. The company name will still be shown.
21
+ // Also ignore "Default Vehicle Type"
22
+ if ((stationName.match(/-/g) || []).length > 3 ||
23
+ stationName === "Default vehicle type") {
24
+ stationName = null;
25
+ }
26
+ if ("vehicleType" in entity &&
27
+ !("availableVehicles" in entity) &&
28
+ ((_a = entity.vehicleType) === null || _a === void 0 ? void 0 : _a.formFactor) === "BICYCLE") {
29
+ stationName = intl.formatMessage({
30
+ defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingBike"],
31
+ description: "Popup title for a free-floating bike",
32
+ id: "otpUi.MapPopup.floatingBike"
33
+ }, { name: stationName });
34
+ }
35
+ else if ("vehicleType" in entity &&
36
+ ((_b = entity.vehicleType) === null || _b === void 0 ? void 0 : _b.formFactor) === "CAR") {
37
+ // TODO: Stop generating this / passing it to the car string? Is it needed?
38
+ // In English we say "Car: " instead
39
+ const network = getNetwork(entity, configCompanies);
40
+ stationName = intl.formatMessage({
41
+ defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingCar"],
42
+ description: "Popup title for a free-floating car",
43
+ id: "otpUi.MapPopup.floatingCar"
44
+ }, {
45
+ company: network,
46
+ name: stationName
47
+ });
48
+ }
49
+ else if ("vehicleType" in entity &&
50
+ !("availableVehicles" in entity) &&
51
+ ((_c = entity.vehicleType) === null || _c === void 0 ? void 0 : _c.formFactor.startsWith("SCOOTER"))) {
52
+ stationName = intl.formatMessage({
53
+ defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingEScooter"],
54
+ description: "Popup title for a free-floating e-scooter",
55
+ id: "otpUi.MapPopup.floatingEScooter"
56
+ }, { name: stationName });
57
+ }
58
+ else if (includeParenthetical && feedName && "code" in entity) {
59
+ stationName = `${stationName} (${feedName} ${entity.code})`;
60
+ }
61
+ return stationName;
62
+ };
58
63
  }
64
+ exports.makeDefaultGetEntityName = makeDefaultGetEntityName;
59
65
  //# sourceMappingURL=util.js.map
package/lib/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","names":["_coreUtils","_interopRequireDefault","require","getNetwork","entity","configCompanies","coreUtils","itinerary","getCompaniesLabelFromNetworks","network","makeDefaultGetEntityName","intl","defaultEnglishMessages","defaultGetEntityName","feedName","stationName","name","id","match","length","isFloatingBike","formatMessage","defaultMessage","description","isFloatingCar","stationNetwork","company","isFloatingVehicle","code"],"sources":["../src/util.ts"],"sourcesContent":["import {\n Agency,\n Company,\n Station,\n Stop,\n TileLayerStation\n} from \"@opentripplanner/types\";\nimport { IntlShape } from \"react-intl\";\nimport coreUtils from \"@opentripplanner/core-utils\";\n\nexport type StopIdAgencyMap = Record<string, Agency>;\nexport type Entity = Station | Stop | TileLayerStation;\n\nexport function getNetwork(entity: Entity, configCompanies: Company[]): string {\n return (\n \"network\" in entity &&\n (coreUtils.itinerary.getCompaniesLabelFromNetworks(\n [entity.network] || [],\n configCompanies\n ) ||\n entity.network)\n );\n}\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: Entity,\n configCompanies: Company[],\n feedName?: string\n ): string | null {\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 // TODO: Stop generating this / passing it to the car string? Is it needed?\n // In English we say \"Car: \" instead\n const stationNetwork = getNetwork(entity, configCompanies);\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: stationNetwork,\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 = `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W,EAAE,qCAAqC;QAClDN,EAAE,EAAE;MACN,CAAC,EACD;QACES,OAAO,EAAED,cAAc;QACvBT,IAAI,EAAED;MACR,CACF,CAAC;IACH,CAAC,MAAM,IAAI,mBAAmB,IAAIX,MAAM,IAAIA,MAAM,CAACuB,iBAAiB,EAAE;MACpE;MACAZ,WAAW,GAAGJ,IAAI,CAACU,aAAa,CAC9B;QACEC,cAAc,EACZV,sBAAsB,CAAC,iCAAiC,CAAC;QAC3DW,WAAW,EAAE,2CAA2C;QACxDN,EAAE,EAAE;MACN,CAAC,EACD;QAAED,IAAI,EAAED;MAAY,CACtB,CAAC;IACH,CAAC,MAAM,IAAID,QAAQ,IAAI,MAAM,IAAIV,MAAM,EAAE;MACvCW,WAAW,GAAG,GAAGA,WAAW,KAAKD,QAAQ,IAAIV,MAAM,CAACwB,IAAI,GAAG;IAC7D;IACA,OAAOb,WAAW;EACpB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;AAMA,6EAAoD;AAKpD,SAAgB,UAAU,CAAC,MAAc,EAAE,eAA0B;IACnE,OAAO,CACL,eAAe,IAAI,MAAM;QACzB,CAAC,oBAAS,CAAC,SAAS,CAAC,6BAA6B,CAChD,MAAM,CAAC,aAAa,CAAC,SAAS,EAC9B,eAAe,CAChB;YACC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAClC,CAAC;AACJ,CAAC;AATD,gCASC;AAED,wDAAwD;AACxD,SAAgB,wBAAwB,CACtC,IAAe,EACf,sBAAiD;IAEjD,OAAO,SAAS,oBAAoB,CAClC,MAAc,EACd,eAA0B,EAC1B,QAAiB,EACjB,oBAAoB,GAAG,IAAI;;QAE3B,IAAI,WAAW,GAAkB,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC;QAC1D,8EAA8E;QAC9E,sEAAsE;QACtE,qCAAqC;QACrC,IACE,CAAC,WAAW,CAAC,KAAK,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AE,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;AAvED,4DAuEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentripplanner/map-popup",
3
- "version": "7.0.0",
3
+ "version": "8.0.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/core-utils": "14.2.0",
15
16
  "@opentripplanner/base-map": "6.0.0",
16
17
  "@opentripplanner/building-blocks": "3.0.1",
17
- "@opentripplanner/core-utils": "13.0.1",
18
18
  "@opentripplanner/from-to-location-picker": "4.0.1"
19
19
  },
20
20
  "devDependencies": {
21
- "@opentripplanner/types": "7.0.0"
21
+ "@opentripplanner/types": "8.2.0"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "^18.2.0",
@@ -1,9 +1,13 @@
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
- import { Station, Stop } from "@opentripplanner/types";
4
+ import { Stop } from "@opentripplanner/types";
5
+ import {
6
+ RentalVehicle,
7
+ VehicleRentalStation
8
+ } from "@opentripplanner/types/otp2";
5
9
  import { IntlProvider } from "react-intl";
6
- import { Meta } from "@storybook/react";
10
+ import { Meta } from "@storybook/react-vite";
7
11
  import MapPopupContents, { Feed } from "./index";
8
12
 
9
13
  // HOC to wrap components with IntlProvider
@@ -68,57 +72,46 @@ const SAMPLE_FEEDS: Feed[] = [
68
72
  }
69
73
  ];
70
74
 
71
- const STATION = {
72
- "stroke-width": 2,
75
+ const VEHICLE_RENTAL_STATION: VehicleRentalStation = {
73
76
  allowDropoff: true,
74
77
  allowPickup: true,
75
- color: "#f00",
78
+ availableVehicles: {
79
+ total: 6,
80
+ byType: [{ count: 6, vehicleType: { formFactor: "BICYCLE" } }]
81
+ },
82
+ availableSpaces: {
83
+ total: 11,
84
+ byType: [{ count: 12, vehicleType: { formFactor: "BICYCLE" } }]
85
+ },
76
86
  id: '"hub_1580"',
77
- isCarStation: false,
78
- isFloatingBike: false,
79
87
  lat: 45.5219604810172,
80
88
  lon: -122.6896771788597,
81
89
  name: "SW Morrison at 18th",
82
- network: "BIKETOWN",
83
- realTimeData: true,
84
- spacesAvailable: 11,
85
- vehiclesAvailable: 6
90
+ rentalNetwork: { networkId: "BIKETOWN" },
91
+ realtime: true
86
92
  };
87
93
 
88
- const FLOATING_VEHICLE = {
89
- "stroke-width": 1,
90
- allowDropoff: false,
91
- allowPickup: true,
92
- color: "#f00",
94
+ const FLOATING_VEHICLE: RentalVehicle = {
95
+ allowPickupNow: true,
93
96
  id: '"bike_6861"',
94
- isCarStation: false,
95
- isFloatingBike: true,
97
+ vehicleType: { formFactor: "BICYCLE" },
96
98
  lat: 45.525486666666666,
97
99
  lon: -122.70486,
98
100
  name: "0541",
99
- network: "BIKETOWN",
100
- realTimeData: true,
101
- spacesAvailable: 0,
102
- vehiclesAvailable: 1
101
+ rentalNetwork: { networkId: "BIKETOWN" }
103
102
  };
104
103
 
105
- const FLOATING_CAR = {
106
- "stroke-width": 1,
107
- allowDropoff: false,
108
- allowPickup: true,
109
- color: "#333",
104
+ const FLOATING_CAR: RentalVehicle = {
105
+ allowPickupNow: true,
110
106
  id: "car_6861",
111
- isCarStation: false,
112
- isFloatingCar: true,
107
+ vehicleType: { formFactor: "CAR" },
113
108
  lat: 52.52,
114
109
  lon: 13.405,
115
110
  name: "0541",
116
- network: "MILES", // https://miles-mobility.com
117
- realTimeData: true,
118
- spacesAvailable: 0
111
+ rentalNetwork: { networkId: "MILES" }
119
112
  };
120
113
 
121
- const getEntityPrefixExample = (entity: Stop | Station) => {
114
+ const getEntityPrefixExample = (entity: Stop | VehicleRentalStation) => {
122
115
  const DemoIcon = styled.span`
123
116
  background-color: blue;
124
117
  border-radius: 50px;
@@ -171,7 +164,7 @@ export const StopEntityNoStopCode = (): JSX.Element => (
171
164
 
172
165
  export const StationEntity = (): JSX.Element => (
173
166
  <MapPopupContents
174
- entity={STATION}
167
+ entity={VEHICLE_RENTAL_STATION}
175
168
  setLocation={action("setLocation")}
176
169
  setViewedStop={action("setViewedStop")}
177
170
  />
@@ -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 hXaHvR">
268
+ <button class="styled__ViewStopButton-sc-12v7ov3-0 bbtcwi">
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,6 +1,7 @@
1
1
  import React, { useCallback } from "react";
2
2
  import FromToLocationPicker from "@opentripplanner/from-to-location-picker";
3
3
 
4
+ import { RentalVehicle, VehicleRentalStation } from "@opentripplanner/types/otp2";
4
5
  // eslint-disable-next-line prettier/prettier
5
6
  import type {
6
7
  Company,
@@ -8,15 +9,15 @@ import type {
8
9
  Location,
9
10
  Stop,
10
11
  StopEventHandler,
11
- TileLayerStation
12
12
  } from "@opentripplanner/types";
13
13
 
14
14
  import { FocusTrapWrapper } from "@opentripplanner/building-blocks";
15
15
  import { flatten } from "flat";
16
16
  import { FormattedMessage, useIntl } from "react-intl";
17
17
  import { Styled } from "@opentripplanner/base-map";
18
+ import coreUtils from "@opentripplanner/core-utils";
18
19
 
19
- import { Entity, getNetwork, makeDefaultGetEntityName, type StopIdAgencyMap } from "./util";
20
+ import { makeDefaultGetEntityName, type StopIdAgencyMap } from "./util";
20
21
  import { ViewStopButton } from "./styled";
21
22
 
22
23
  // Load the default messages.
@@ -36,7 +37,7 @@ export type Feed = {
36
37
  };
37
38
 
38
39
 
39
- const generateLocation = (entity: Entity, name: string) => {
40
+ const generateLocation = (entity: MapPopupEntity, name: string) => {
40
41
  // @ts-expect-error some of these values may be null, but that's ok
41
42
  const { lon: entityLon, lat: entityLat, x, y } = entity
42
43
 
@@ -47,7 +48,7 @@ const generateLocation = (entity: Entity, name: string) => {
47
48
  return { lat, lon, name };
48
49
  }
49
50
 
50
- const StationHubDetails = ({ station }: { station: TileLayerStation }) => {
51
+ const StationHubDetails = ({ availableVehicles, availableSpaces }: { availableVehicles: number, availableSpaces: number }) => {
51
52
  return (
52
53
  <Styled.PopupRow>
53
54
  <div>
@@ -57,7 +58,7 @@ const StationHubDetails = ({ station }: { station: TileLayerStation }) => {
57
58
  }
58
59
  description="Label text for the number of bikes available"
59
60
  id="otpUi.MapPopup.availableBikes"
60
- values={{ value: station.vehiclesAvailable }}
61
+ values={{ value: availableVehicles }}
61
62
  />
62
63
  </div>
63
64
  <div>
@@ -67,14 +68,14 @@ const StationHubDetails = ({ station }: { station: TileLayerStation }) => {
67
68
  }
68
69
  description="Label text for the number of docks available"
69
70
  id="otpUi.MapPopup.availableDocks"
70
- values={{ value: station.spacesAvailable }}
71
+ values={{ value: availableSpaces }}
71
72
  />
72
73
  </div>
73
74
  </Styled.PopupRow>
74
75
  )
75
76
  }
76
77
 
77
- const StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {
78
+ const StopDetails = ({ id, feedName, setViewedStop }: { id: string, feedName?: string, setViewedStop: () => void; }) => {
78
79
  return (
79
80
  <Styled.PopupRow>
80
81
  {id &&
@@ -84,6 +85,7 @@ const StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => v
84
85
  description="Displays the stop id"
85
86
  id="otpUi.MapPopup.stopId"
86
87
  values={{
88
+ feedName,
87
89
  stopId: id
88
90
  }}
89
91
  />
@@ -99,20 +101,20 @@ const StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => v
99
101
  )
100
102
  }
101
103
 
104
+ type MapPopupEntity = Stop | VehicleRentalStation | RentalVehicle
105
+
102
106
  type Props = {
103
107
  closePopup?: (arg?: boolean) => void
104
108
  configCompanies?: ConfiguredCompany[];
105
- entity: Entity
106
- getEntityName?: (entity: Entity, configCompanies: Company[], feedName?: string) => string;
107
- getEntityPrefix?: (entity: Entity) => JSX.Element
109
+ entity: MapPopupEntity
110
+ getEntityName?: (entity: MapPopupEntity, configCompanies: Company[], feedName?: string, includeParenthetical?: boolean) => string;
111
+ getEntityPrefix?: (entity: MapPopupEntity) => JSX.Element
108
112
  feeds?: Feed[]
109
113
  setLocation?: ({ location, locationType }: { location: Location, locationType: string }) => void;
110
114
  setViewedStop?: StopEventHandler;
111
115
  };
112
116
 
113
- function entityIsStation(entity: Entity): entity is TileLayerStation {
114
- return "vehiclesAvailable" in entity
115
- }
117
+ const entityIsStop = (entity: MapPopupEntity): entity is Stop => "gtfsId" in entity;
116
118
 
117
119
  /**
118
120
  * Renders a map popup for a stop, scooter, or shared bike
@@ -142,12 +144,13 @@ export function MapPopup({
142
144
  }
143
145
 
144
146
  const name = getNameFunc(entity, configCompanies, feedName);
147
+ const titleName = getNameFunc(entity, configCompanies, feedName, false);
145
148
 
146
- const stationNetwork = getNetwork(entity, configCompanies);
149
+ const stationNetwork = "rentalNetwork" in entity && (coreUtils.itinerary.getCompaniesLabelFromNetworks(entity?.rentalNetwork.networkId, configCompanies) || entity?.rentalNetwork.networkId);
147
150
 
148
- const bikesAvailablePresent = entityIsStation(entity)
149
- const entityIsStationHub = bikesAvailablePresent && entity.vehiclesAvailable !== undefined && !entity.isFloatingBike;
150
- const stopId = !bikesAvailablePresent && "code" in entity && entity.code;
151
+ const vehiclesAvailable = "availableVehicles" in entity;
152
+ const entityIsStationHub = vehiclesAvailable && entity?.availableVehicles !== undefined;
153
+ const stopId = entityIsStop(entity) ? entity.code : "";
151
154
  const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, "")}-popup`
152
155
 
153
156
  return (
@@ -159,16 +162,17 @@ export function MapPopup({
159
162
  defaultMessage={defaultMessages["otpUi.MapPopup.popupTitle"]}
160
163
  description="Text for title of the popup, contains an optional company name"
161
164
  id="otpUi.MapPopup.popupTitle"
162
- values={{ name, stationNetwork }}
165
+ values={{ name: titleName, stationNetwork }}
163
166
  />
164
167
  </Styled.PopupTitle>
165
168
  {/* render dock info if it is available */}
166
- {entityIsStationHub && <StationHubDetails station={entity} />}
169
+ {entityIsStationHub && <StationHubDetails availableSpaces={entity.availableSpaces?.total} availableVehicles={entity.availableVehicles?.total} />}
167
170
 
168
171
  {/* render stop viewer link if available */}
169
- {setViewedStop && !bikesAvailablePresent && (
172
+ {setViewedStop && entityIsStop(entity) && (
170
173
  <StopDetails
171
174
  id={stopId}
175
+ feedName={feedName}
172
176
  setViewedStop={useCallback(() => setViewedStop(entity as Stop), [entity])}
173
177
  />
174
178
  )}
package/src/util.ts CHANGED
@@ -1,24 +1,22 @@
1
1
  import {
2
- Agency,
3
- Company,
4
- Station,
5
- Stop,
6
- TileLayerStation
7
- } from "@opentripplanner/types";
2
+ RentalVehicle,
3
+ VehicleRentalStation
4
+ } from "@opentripplanner/types/otp2";
5
+ import { Agency, Company, Stop } from "@opentripplanner/types";
8
6
  import { IntlShape } from "react-intl";
9
7
  import coreUtils from "@opentripplanner/core-utils";
10
8
 
11
9
  export type StopIdAgencyMap = Record<string, Agency>;
12
- export type Entity = Station | Stop | TileLayerStation;
10
+ export type Entity = VehicleRentalStation | Stop | RentalVehicle;
13
11
 
14
12
  export function getNetwork(entity: Entity, configCompanies: Company[]): string {
15
13
  return (
16
- "network" in entity &&
14
+ "rentalNetwork" in entity &&
17
15
  (coreUtils.itinerary.getCompaniesLabelFromNetworks(
18
- [entity.network] || [],
16
+ entity.rentalNetwork.networkId,
19
17
  configCompanies
20
18
  ) ||
21
- entity.network)
19
+ entity.rentalNetwork.networkId)
22
20
  );
23
21
  }
24
22
 
@@ -30,7 +28,8 @@ export function makeDefaultGetEntityName(
30
28
  return function defaultGetEntityName(
31
29
  entity: Entity,
32
30
  configCompanies: Company[],
33
- feedName?: string
31
+ feedName?: string,
32
+ includeParenthetical = true
34
33
  ): string | null {
35
34
  let stationName: string | null = entity.name || entity.id;
36
35
  // If the station name or id is a giant UUID (with more than 3 "-" characters)
@@ -43,7 +42,11 @@ export function makeDefaultGetEntityName(
43
42
  stationName = null;
44
43
  }
45
44
 
46
- if ("isFloatingBike" in entity && entity.isFloatingBike) {
45
+ if (
46
+ "vehicleType" in entity &&
47
+ !("availableVehicles" in entity) &&
48
+ entity.vehicleType?.formFactor === "BICYCLE"
49
+ ) {
47
50
  stationName = intl.formatMessage(
48
51
  {
49
52
  defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingBike"],
@@ -52,10 +55,13 @@ export function makeDefaultGetEntityName(
52
55
  },
53
56
  { name: stationName }
54
57
  );
55
- } else if ("isFloatingCar" in entity && entity.isFloatingCar) {
58
+ } else if (
59
+ "vehicleType" in entity &&
60
+ entity.vehicleType?.formFactor === "CAR"
61
+ ) {
56
62
  // TODO: Stop generating this / passing it to the car string? Is it needed?
57
63
  // In English we say "Car: " instead
58
- const stationNetwork = getNetwork(entity, configCompanies);
64
+ const network = getNetwork(entity, configCompanies);
59
65
  stationName = intl.formatMessage(
60
66
  {
61
67
  defaultMessage: defaultEnglishMessages["otpUi.MapPopup.floatingCar"],
@@ -63,12 +69,15 @@ export function makeDefaultGetEntityName(
63
69
  id: "otpUi.MapPopup.floatingCar"
64
70
  },
65
71
  {
66
- company: stationNetwork,
72
+ company: network,
67
73
  name: stationName
68
74
  }
69
75
  );
70
- } else if ("isFloatingVehicle" in entity && entity.isFloatingVehicle) {
71
- // assumes that all floating vehicles are E-scooters
76
+ } else if (
77
+ "vehicleType" in entity &&
78
+ !("availableVehicles" in entity) &&
79
+ entity.vehicleType?.formFactor.startsWith("SCOOTER")
80
+ ) {
72
81
  stationName = intl.formatMessage(
73
82
  {
74
83
  defaultMessage:
@@ -78,7 +87,7 @@ export function makeDefaultGetEntityName(
78
87
  },
79
88
  { name: stationName }
80
89
  );
81
- } else if (feedName && "code" in entity) {
90
+ } else if (includeParenthetical && feedName && "code" in entity) {
82
91
  stationName = `${stationName} (${feedName} ${entity.code})`;
83
92
  }
84
93
  return stationName;