@opentripplanner/map-popup 7.0.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/esm/index.js +5 -1
- package/esm/index.js.map +1 -1
- package/esm/util.js +3 -2
- package/esm/util.js.map +1 -1
- package/i18n/en-US.yml +3 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +91 -124
- package/lib/index.js.map +1 -1
- package/lib/styled.js +17 -10
- package/lib/styled.js.map +1 -1
- package/lib/util.d.ts +1 -1
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +53 -52
- package/lib/util.js.map +1 -1
- package/package.json +4 -4
- package/src/MapPopup.story.tsx +2 -2
- package/src/__snapshots__/MapPopup.story.tsx.snap +2 -2
- package/src/index.tsx +6 -3
- package/src/util.ts +4 -3
- package/tsconfig.tsbuildinfo +1 -1
package/lib/util.js
CHANGED
|
@@ -1,59 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
9
|
+
return ("network" in entity &&
|
|
10
|
+
(core_utils_1.default.itinerary.getCompaniesLabelFromNetworks([entity.network], configCompanies) ||
|
|
11
|
+
entity.network));
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
exports.getNetwork = getNetwork;
|
|
14
14
|
// eslint-disable-next-line import/prefer-default-export
|
|
15
15
|
function makeDefaultGetEntityName(intl, defaultEnglishMessages) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
+
};
|
|
58
58
|
}
|
|
59
|
+
exports.makeDefaultGetEntityName = makeDefaultGetEntityName;
|
|
59
60
|
//# sourceMappingURL=util.js.map
|
package/lib/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;AAQA,6EAAoD;AAKpD,SAAgB,UAAU,CAAC,MAAc,EAAE,eAA0B;IACnE,OAAO,CACL,SAAS,IAAI,MAAM;QACnB,CAAC,oBAAS,CAAC,SAAS,CAAC,6BAA6B,CAChD,CAAC,MAAM,CAAC,OAAO,CAAC,EAChB,eAAe,CAChB;YACC,MAAM,CAAC,OAAO,CAAC,CAClB,C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AC9B;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": "7.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",
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"private": false,
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"flat": "^5.0.2",
|
|
15
|
-
"@opentripplanner/base-map": "6.0.0",
|
|
16
15
|
"@opentripplanner/building-blocks": "3.0.1",
|
|
17
|
-
"@opentripplanner/
|
|
16
|
+
"@opentripplanner/base-map": "6.0.0",
|
|
17
|
+
"@opentripplanner/core-utils": "14.0.0",
|
|
18
18
|
"@opentripplanner/from-to-location-picker": "4.0.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@opentripplanner/types": "
|
|
21
|
+
"@opentripplanner/types": "8.0.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "^18.2.0",
|
package/src/MapPopup.story.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { action } from "
|
|
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
|
|
@@ -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 & SW 2nd
|
|
395
|
+
W Burnside & 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
|
@@ -74,7 +74,7 @@ const StationHubDetails = ({ station }: { station: TileLayerStation }) => {
|
|
|
74
74
|
)
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
const StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => void; }) => {
|
|
77
|
+
const StopDetails = ({ id, feedName, setViewedStop }: { id: string, feedName?: string, setViewedStop: () => void; }) => {
|
|
78
78
|
return (
|
|
79
79
|
<Styled.PopupRow>
|
|
80
80
|
{id &&
|
|
@@ -84,6 +84,7 @@ const StopDetails = ({ id, setViewedStop }: { id: string, setViewedStop: () => v
|
|
|
84
84
|
description="Displays the stop id"
|
|
85
85
|
id="otpUi.MapPopup.stopId"
|
|
86
86
|
values={{
|
|
87
|
+
feedName,
|
|
87
88
|
stopId: id
|
|
88
89
|
}}
|
|
89
90
|
/>
|
|
@@ -103,7 +104,7 @@ type Props = {
|
|
|
103
104
|
closePopup?: (arg?: boolean) => void
|
|
104
105
|
configCompanies?: ConfiguredCompany[];
|
|
105
106
|
entity: Entity
|
|
106
|
-
getEntityName?: (entity: Entity, configCompanies: Company[], feedName?: string) => string;
|
|
107
|
+
getEntityName?: (entity: Entity, configCompanies: Company[], feedName?: string, includeParenthetical?: boolean) => string;
|
|
107
108
|
getEntityPrefix?: (entity: Entity) => JSX.Element
|
|
108
109
|
feeds?: Feed[]
|
|
109
110
|
setLocation?: ({ location, locationType }: { location: Location, locationType: string }) => void;
|
|
@@ -142,6 +143,7 @@ export function MapPopup({
|
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
const name = getNameFunc(entity, configCompanies, feedName);
|
|
146
|
+
const titleName = getNameFunc(entity, configCompanies, feedName, false);
|
|
145
147
|
|
|
146
148
|
const stationNetwork = getNetwork(entity, configCompanies);
|
|
147
149
|
|
|
@@ -159,7 +161,7 @@ export function MapPopup({
|
|
|
159
161
|
defaultMessage={defaultMessages["otpUi.MapPopup.popupTitle"]}
|
|
160
162
|
description="Text for title of the popup, contains an optional company name"
|
|
161
163
|
id="otpUi.MapPopup.popupTitle"
|
|
162
|
-
values={{ name, stationNetwork }}
|
|
164
|
+
values={{ name: titleName, stationNetwork }}
|
|
163
165
|
/>
|
|
164
166
|
</Styled.PopupTitle>
|
|
165
167
|
{/* render dock info if it is available */}
|
|
@@ -169,6 +171,7 @@ export function MapPopup({
|
|
|
169
171
|
{setViewedStop && !bikesAvailablePresent && (
|
|
170
172
|
<StopDetails
|
|
171
173
|
id={stopId}
|
|
174
|
+
feedName={feedName}
|
|
172
175
|
setViewedStop={useCallback(() => setViewedStop(entity as Stop), [entity])}
|
|
173
176
|
/>
|
|
174
177
|
)}
|
package/src/util.ts
CHANGED
|
@@ -15,7 +15,7 @@ export function getNetwork(entity: Entity, configCompanies: Company[]): string {
|
|
|
15
15
|
return (
|
|
16
16
|
"network" in entity &&
|
|
17
17
|
(coreUtils.itinerary.getCompaniesLabelFromNetworks(
|
|
18
|
-
[entity.network]
|
|
18
|
+
[entity.network],
|
|
19
19
|
configCompanies
|
|
20
20
|
) ||
|
|
21
21
|
entity.network)
|
|
@@ -30,7 +30,8 @@ export function makeDefaultGetEntityName(
|
|
|
30
30
|
return function defaultGetEntityName(
|
|
31
31
|
entity: Entity,
|
|
32
32
|
configCompanies: Company[],
|
|
33
|
-
feedName?: string
|
|
33
|
+
feedName?: string,
|
|
34
|
+
includeParenthetical = true
|
|
34
35
|
): string | null {
|
|
35
36
|
let stationName: string | null = entity.name || entity.id;
|
|
36
37
|
// If the station name or id is a giant UUID (with more than 3 "-" characters)
|
|
@@ -78,7 +79,7 @@ export function makeDefaultGetEntityName(
|
|
|
78
79
|
},
|
|
79
80
|
{ name: stationName }
|
|
80
81
|
);
|
|
81
|
-
} else if (feedName && "code" in entity) {
|
|
82
|
+
} else if (includeParenthetical && feedName && "code" in entity) {
|
|
82
83
|
stationName = `${stationName} (${feedName} ${entity.code})`;
|
|
83
84
|
}
|
|
84
85
|
return stationName;
|