@opentripplanner/trip-details 2.1.4 → 2.2.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 +52 -3
- package/esm/index.js.map +1 -1
- package/esm/styled.js +24 -16
- package/esm/styled.js.map +1 -1
- package/esm/trip-detail.js +5 -9
- package/esm/trip-detail.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/i18n/en-US.yml +4 -0
- package/i18n/fr.yml +4 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +49 -2
- package/lib/index.js.map +1 -1
- package/lib/styled.d.ts +2 -0
- package/lib/styled.d.ts.map +1 -1
- package/lib/styled.js +31 -17
- package/lib/styled.js.map +1 -1
- package/lib/trip-detail.d.ts.map +1 -1
- package/lib/trip-detail.js +7 -9
- package/lib/trip-detail.js.map +1 -1
- package/lib/types.d.ts +11 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +5 -4
- package/src/TripDetails.story.tsx +8 -2
- package/src/index.tsx +70 -2
- package/src/styled.ts +4 -0
- package/src/trip-detail.tsx +9 -14
- package/src/types.ts +10 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/__unpublished__/external-types.d.ts +0 -22
package/esm/index.js
CHANGED
|
@@ -2,10 +2,11 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import flatten from "flat";
|
|
3
3
|
import coreUtils from "@opentripplanner/core-utils";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import { FormattedMessage } from "react-intl";
|
|
5
|
+
import { FormattedMessage, FormattedNumber } from "react-intl";
|
|
6
6
|
import { CalendarAlt } from "@styled-icons/fa-solid/CalendarAlt";
|
|
7
7
|
import { Heartbeat } from "@styled-icons/fa-solid/Heartbeat";
|
|
8
8
|
import { MoneyBillAlt } from "@styled-icons/fa-solid/MoneyBillAlt";
|
|
9
|
+
import { Leaf } from "@styled-icons/fa-solid/Leaf";
|
|
9
10
|
import { Route } from "@styled-icons/fa-solid/Route";
|
|
10
11
|
import * as S from "./styled";
|
|
11
12
|
import TripDetail from "./trip-detail";
|
|
@@ -18,10 +19,15 @@ import defaultEnglishMessages from "../i18n/en-US.yml"; // HACK: We should flatt
|
|
|
18
19
|
// - the yaml loader for jest returns messages with flattened ids.
|
|
19
20
|
|
|
20
21
|
var defaultMessages = flatten(defaultEnglishMessages);
|
|
22
|
+
|
|
23
|
+
var subText = function subText(contents) {
|
|
24
|
+
return /*#__PURE__*/React.createElement("sub", null, contents);
|
|
25
|
+
};
|
|
21
26
|
/**
|
|
22
27
|
* Helper function to specify the link to dietary table.
|
|
23
28
|
*/
|
|
24
29
|
|
|
30
|
+
|
|
25
31
|
function dietaryLink(contents) {
|
|
26
32
|
return /*#__PURE__*/React.createElement("a", {
|
|
27
33
|
href: "https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4",
|
|
@@ -29,6 +35,14 @@ function dietaryLink(contents) {
|
|
|
29
35
|
target: "_blank"
|
|
30
36
|
}, contents);
|
|
31
37
|
}
|
|
38
|
+
|
|
39
|
+
function CO2DescriptionLink(contents) {
|
|
40
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
41
|
+
href: "https://www.itf-oecd.org/sites/default/files/life-cycle-assessment-calculations-2020.xlsx",
|
|
42
|
+
rel: "noopener noreferrer",
|
|
43
|
+
target: "_blank"
|
|
44
|
+
}, contents);
|
|
45
|
+
}
|
|
32
46
|
/**
|
|
33
47
|
* Default rendering if no component is provided for the CaloriesDetails
|
|
34
48
|
* slot in the TripDetails component.
|
|
@@ -95,7 +109,8 @@ export function TripDetails(_ref3) {
|
|
|
95
109
|
fareDetailsLayout = _ref3.fareDetailsLayout,
|
|
96
110
|
_ref3$fareKeyNameMap = _ref3.fareKeyNameMap,
|
|
97
111
|
fareKeyNameMap = _ref3$fareKeyNameMap === void 0 ? {} : _ref3$fareKeyNameMap,
|
|
98
|
-
itinerary = _ref3.itinerary
|
|
112
|
+
itinerary = _ref3.itinerary,
|
|
113
|
+
co2Config = _ref3.co2Config;
|
|
99
114
|
// process the transit fare
|
|
100
115
|
var fareResult = coreUtils.itinerary.calculateTncFares(itinerary);
|
|
101
116
|
var currencyCode = fareResult.currencyCode,
|
|
@@ -177,8 +192,9 @@ export function TripDetails(_ref3) {
|
|
|
177
192
|
var _coreUtils$itinerary$ = coreUtils.itinerary.calculatePhysicalActivity(itinerary),
|
|
178
193
|
bikeDuration = _coreUtils$itinerary$.bikeDuration,
|
|
179
194
|
caloriesBurned = _coreUtils$itinerary$.caloriesBurned,
|
|
180
|
-
walkDuration = _coreUtils$itinerary$.walkDuration;
|
|
195
|
+
walkDuration = _coreUtils$itinerary$.walkDuration;
|
|
181
196
|
|
|
197
|
+
var co2 = coreUtils.itinerary.calculateEmissions(itinerary, co2Config === null || co2Config === void 0 ? void 0 : co2Config.carbonIntensity, co2Config === null || co2Config === void 0 ? void 0 : co2Config.units); // Parse flex info and generate appropriate strings
|
|
182
198
|
|
|
183
199
|
var containsFlex = itinerary.legs.some(coreUtils.itinerary.isFlex);
|
|
184
200
|
var pickupBookingInfo = itinerary.legs.map(function (leg) {
|
|
@@ -191,6 +207,9 @@ export function TripDetails(_ref3) {
|
|
|
191
207
|
}).filter(function (info) {
|
|
192
208
|
return !!info;
|
|
193
209
|
});
|
|
210
|
+
var totalDistance = itinerary.legs.reduce(function (total, leg) {
|
|
211
|
+
return total + leg.distance;
|
|
212
|
+
}, 0);
|
|
194
213
|
return /*#__PURE__*/React.createElement(S.TripDetails, {
|
|
195
214
|
className: className
|
|
196
215
|
}, /*#__PURE__*/React.createElement(S.TripDetailsHeader, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
@@ -243,6 +262,36 @@ export function TripDetails(_ref3) {
|
|
|
243
262
|
calories: caloriesBurned,
|
|
244
263
|
walkSeconds: walkDuration
|
|
245
264
|
})
|
|
265
|
+
}), co2 > 0 && (co2Config === null || co2Config === void 0 ? void 0 : co2Config.enabled) && /*#__PURE__*/React.createElement(TripDetail, {
|
|
266
|
+
icon: /*#__PURE__*/React.createElement(Leaf, {
|
|
267
|
+
size: 17
|
|
268
|
+
}),
|
|
269
|
+
summary: /*#__PURE__*/React.createElement(S.CO2Summary, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
270
|
+
defaultMessage: defaultMessages["otpUi.TripDetails.co2"],
|
|
271
|
+
description: "Text showing the quantity of CO2 emitted by this trip.",
|
|
272
|
+
id: "otpUi.TripDetails.co2",
|
|
273
|
+
values: {
|
|
274
|
+
co2: /*#__PURE__*/React.createElement(FormattedNumber, {
|
|
275
|
+
value: Math.round(co2) // eslint-disable-next-line react/style-prop-object
|
|
276
|
+
,
|
|
277
|
+
style: "unit",
|
|
278
|
+
unit: (co2Config === null || co2Config === void 0 ? void 0 : co2Config.units) || "gram",
|
|
279
|
+
unitDisplay: "narrow"
|
|
280
|
+
}),
|
|
281
|
+
strong: boldText,
|
|
282
|
+
sub: subText
|
|
283
|
+
}
|
|
284
|
+
})),
|
|
285
|
+
description: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
286
|
+
defaultMessage: defaultMessages["otpUi.TripDetails.co2description"],
|
|
287
|
+
values: {
|
|
288
|
+
link: CO2DescriptionLink,
|
|
289
|
+
sub: subText,
|
|
290
|
+
totalDistance: totalDistance
|
|
291
|
+
},
|
|
292
|
+
description: "Text explaining how the CO2 emissions is calculated.",
|
|
293
|
+
id: "otpUi.TripDetails.co2description"
|
|
294
|
+
})
|
|
246
295
|
}), containsFlex && /*#__PURE__*/React.createElement(TripDetail, {
|
|
247
296
|
summary: /*#__PURE__*/React.createElement(S.FlexSummary, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
248
297
|
defaultMessage: defaultMessages["otpUi.TripDetails.tripIncludesFlex"],
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx"],"names":["flatten","coreUtils","React","FormattedMessage","CalendarAlt","Heartbeat","MoneyBillAlt","Route","S","TripDetail","FareLegTable","boldText","renderFare","defaultEnglishMessages","defaultMessages","dietaryLink","contents","DefaultCaloriesDetails","bikeSeconds","calories","walkSeconds","bikeMinutes","Math","round","strong","walkMinutes","TransitFare","fareKey","fareNameFallback","fareKeyNameMap","transitFares","currentFare","name","value","currency","currencyCode","cents","TripDetails","CaloriesDetails","className","defaultFareKey","DepartureDetails","FareDetails","fareDetailsLayout","itinerary","fareResult","calculateTncFares","maxTNCFare","minTNCFare","fare","fareDetails","details","companies","legs","forEach","leg","tncData","company","fareKeys","Object","keys","sort","length","defaultFare","TransitFareWrapper","TransitFareSingle","display","map","toLowerCase","departureDate","Date","startTime","calculatePhysicalActivity","bikeDuration","caloriesBurned","walkDuration","containsFlex","some","isFlex","pickupBookingInfo","filter","info","dropOffBookingInfo","extraMessage","Set","message","join","Styled"],"mappings":";AAAA,OAAOA,OAAP,MAAoB,MAApB;AACA,OAAOC,SAAP,MAAsB,6BAAtB;AACA,OAAOC,KAAP,MAAoC,OAApC;AACA,SAASC,gBAAT,QAAiC,YAAjC;AACA,SAASC,WAAT,QAA4B,oCAA5B;AACA,SAASC,SAAT,QAA0B,kCAA1B;AACA,SAASC,YAAT,QAA6B,qCAA7B;AACA,SAASC,KAAT,QAAsB,8BAAtB;AAEA,OAAO,KAAKC,CAAZ,MAAmB,UAAnB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,YAAP,MAAyB,cAAzB;AACA,SAASC,QAAT,EAAmBC,UAAnB,QAAqC,SAArC;AAQA;AACA,OAAOC,sBAAP,MAAmC,mBAAnC,C,CAEA;AACA;AACA;AACA;;AACA,IAAMC,eAAuC,GAAGd,OAAO,CAACa,sBAAD,CAAvD;AAEA;AACA;AACA;;AACA,SAASE,WAAT,CAAqBC,QAArB,EAA2D;AACzD,sBACE;AACE,IAAA,IAAI,EAAC,gFADP;AAEE,IAAA,GAAG,EAAC,qBAFN;AAGE,IAA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,IAAI,CAACI,OAAT;AAAA,SAA3B,CAFF,GADS,EAKZC,IALY,CAKP,GALO;AADR;AANV,MADF,CAFJ;AAoBE,IAAA,IAAI,eAAE,oBAAC,KAAD;AAAO,MAAA,IAAI,EAAE;AAAb;AApBR,IAnEJ,CARF,CADF;AAsGD;AAED,eAAejD,WAAf,C,CAEA;;AACA,SAAS7B,CAAC,IAAI+E,MAAd","sourcesContent":["import flatten from \"flat\";\nimport coreUtils from \"@opentripplanner/core-utils\";\nimport React, { ReactElement } from \"react\";\nimport { FormattedMessage } from \"react-intl\";\nimport { CalendarAlt } from \"@styled-icons/fa-solid/CalendarAlt\";\nimport { Heartbeat } from \"@styled-icons/fa-solid/Heartbeat\";\nimport { MoneyBillAlt } from \"@styled-icons/fa-solid/MoneyBillAlt\";\nimport { Route } from \"@styled-icons/fa-solid/Route\";\n\nimport * as S from \"./styled\";\nimport TripDetail from \"./trip-detail\";\nimport FareLegTable from \"./fare-table\";\nimport { boldText, renderFare } from \"./utils\";\n\nimport {\n CaloriesDetailsProps,\n TransitFareProps,\n TripDetailsProps\n} from \"./types\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\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.\nconst defaultMessages: Record<string, string> = flatten(defaultEnglishMessages);\n\n/**\n * Helper function to specify the link to dietary table.\n */\nfunction dietaryLink(contents: ReactElement): ReactElement {\n return (\n <a\n href=\"https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {contents}\n </a>\n );\n}\n/**\n * Default rendering if no component is provided for the CaloriesDetails\n * slot in the TripDetails component.\n */\nfunction DefaultCaloriesDetails({\n bikeSeconds,\n calories,\n walkSeconds\n}: CaloriesDetailsProps): ReactElement {\n return (\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.caloriesDescription\"]}\n description=\"Text describing how the calories relate to the walking and biking duration of a trip.\"\n id=\"otpUi.TripDetails.caloriesDescription\"\n values={{\n bikeMinutes: Math.round(bikeSeconds / 60),\n calories: Math.round(calories),\n dietaryLink,\n strong: boldText,\n walkMinutes: Math.round(walkSeconds / 60)\n }}\n />\n );\n}\n\n/**\n * Helper component that renders a transit fare entry.\n */\nconst TransitFare = ({\n fareKey,\n fareNameFallback,\n fareKeyNameMap,\n transitFares\n}: TransitFareProps): ReactElement => {\n const currentFare = transitFares[fareKey];\n\n return (\n <span>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.transitFareEntry\"]}\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFareEntry\"\n values={{\n name: fareKeyNameMap[fareKey] || fareNameFallback || fareKey,\n strong: boldText,\n value: renderFare(\n currentFare.currency.currencyCode,\n currentFare.cents / 100\n )\n }}\n />\n </span>\n );\n};\n\n/**\n * Renders trip details such as departure instructions, fare amount, and calories spent.\n */\nexport function TripDetails({\n CaloriesDetails = DefaultCaloriesDetails,\n className = \"\",\n defaultFareKey = \"regular\",\n DepartureDetails = null,\n FareDetails = null,\n fareDetailsLayout,\n fareKeyNameMap = {},\n itinerary\n}: TripDetailsProps): ReactElement {\n // process the transit fare\n const fareResult = coreUtils.itinerary.calculateTncFares(itinerary);\n const { currencyCode, maxTNCFare, minTNCFare } = fareResult;\n const transitFares = itinerary?.fare?.fare;\n const fareDetails = itinerary.fare?.details;\n\n let companies = \"\";\n itinerary.legs.forEach(leg => {\n if (leg.tncData) {\n companies = leg.tncData.company;\n }\n });\n let fare;\n\n const fareKeys = transitFares && Object.keys(transitFares).sort();\n\n if (transitFares && fareKeys.length > 0) {\n let defaultFare = defaultFareKey;\n if (!transitFares[defaultFareKey]) {\n defaultFare = \"regular\";\n }\n\n // Depending on if there are additional fares to display either render a <span> or a <details>\n const TransitFareWrapper =\n transitFares && fareKeys.length > 1 ? S.TransitFare : S.TransitFareSingle;\n\n fare = (\n <S.Fare>\n <TransitFareWrapper>\n <summary style={{ display: fareKeys.length > 1 ? \"list-item\" : \"\" }}>\n <TransitFare\n fareNameFallback={\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.transitFare\"]\n }\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFare\"\n />\n }\n fareKey={defaultFare}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n </summary>\n {fareDetailsLayout ? (\n // Show full ƒare details by leg\n <FareLegTable\n layout={fareDetailsLayout}\n legs={itinerary.legs}\n transitFareDetails={fareDetails}\n transitFares={transitFares}\n />\n ) : (\n // Just show the fares for each payment type\n fareKeys.map(fareKey => {\n // Don't show the default fare twice!\n if (fareKey === defaultFare) {\n return null;\n }\n return (\n <TransitFare\n fareKey={fareKey}\n key={fareKey}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n );\n })\n )}\n </TransitFareWrapper>\n {minTNCFare !== 0 && (\n <S.TNCFare>\n <br />\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.tncFare\"]}\n description=\"Text showing the price paid to transportation network companies.\"\n id=\"otpUi.TripDetails.tncFare\"\n values={{\n companies: (\n // S.TNCFareCompanies capitalizes the TNC company ID (e.g. \"COMPANY\")\n // after it is converted to lowercase, so it renders as \"Company\".\n <S.TNCFareCompanies>\n {companies.toLowerCase()}\n </S.TNCFareCompanies>\n ),\n maxTNCFare: renderFare(currencyCode, maxTNCFare),\n minTNCFare: renderFare(currencyCode, minTNCFare),\n strong: boldText\n }}\n />\n </S.TNCFare>\n )}\n </S.Fare>\n );\n }\n\n const departureDate = new Date(itinerary.startTime);\n\n // Compute calories burned.\n const {\n bikeDuration,\n caloriesBurned,\n walkDuration\n } = coreUtils.itinerary.calculatePhysicalActivity(itinerary);\n\n // Parse flex info and generate appropriate strings\n const containsFlex = itinerary.legs.some(coreUtils.itinerary.isFlex);\n const pickupBookingInfo = itinerary.legs\n .map(leg => leg.pickupBookingInfo)\n .filter(info => !!info);\n const dropOffBookingInfo = itinerary.legs\n .map(leg => leg.dropOffBookingInfo)\n .filter(info => !!info);\n\n return (\n <S.TripDetails className={className}>\n <S.TripDetailsHeader>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.title\"]}\n description=\"Title (heading) text of the component.\"\n id=\"otpUi.TripDetails.title\"\n />\n </S.TripDetailsHeader>\n <S.TripDetailsBody>\n <TripDetail\n // Any custom description for the Departure message needs to be handled by the slot.\n description={\n DepartureDetails && (\n <DepartureDetails departureDate={departureDate} />\n )\n }\n icon={<CalendarAlt size={17} />}\n summary={\n <S.Timing>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.departure\"]}\n description=\"Text showing the departure date/time for a trip.\"\n id=\"otpUi.TripDetails.departure\"\n values={{\n departureDate,\n strong: boldText\n }}\n />\n </S.Timing>\n }\n />\n {fare && (\n <TripDetail\n // Any custom description for the transit fare needs to be handled by the slot.\n description={\n FareDetails && (\n <FareDetails\n maxTNCFare={maxTNCFare}\n minTNCFare={minTNCFare}\n transitFares={transitFares}\n />\n )\n }\n icon={<MoneyBillAlt size={17} />}\n summary={fare}\n />\n )}\n {caloriesBurned > 0 && (\n <TripDetail\n icon={<Heartbeat size={17} />}\n summary={\n <S.CaloriesSummary>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.calories\"]}\n description=\"Text showing the number of calories for the walking and biking legs of a trip.\"\n id=\"otpUi.TripDetails.calories\"\n values={{\n calories: caloriesBurned,\n strong: boldText\n }}\n />\n </S.CaloriesSummary>\n }\n description={\n CaloriesDetails && (\n <CaloriesDetails\n bikeSeconds={bikeDuration}\n calories={caloriesBurned}\n walkSeconds={walkDuration}\n />\n )\n }\n />\n )}\n {containsFlex && (\n <TripDetail\n summary={\n <S.FlexSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.tripIncludesFlex\"]\n }\n description=\"Text stating that portions of the trip include a flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.tripIncludesFlex\"\n values={{\n extraMessage: [\n ...new Set([\n ...pickupBookingInfo.map(info => info.message),\n ...dropOffBookingInfo.map(info => info.message)\n ])\n ].join(\" \")\n }}\n />\n </S.FlexSummary>\n }\n icon={<Route size={17} />}\n />\n )}\n </S.TripDetailsBody>\n </S.TripDetails>\n );\n}\n\nexport default TripDetails;\n\n// Rename styled components for export\nexport { S as Styled };\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["flatten","coreUtils","React","FormattedMessage","FormattedNumber","CalendarAlt","Heartbeat","MoneyBillAlt","Leaf","Route","S","TripDetail","FareLegTable","boldText","renderFare","defaultEnglishMessages","defaultMessages","subText","contents","dietaryLink","CO2DescriptionLink","DefaultCaloriesDetails","bikeSeconds","calories","walkSeconds","bikeMinutes","Math","round","strong","walkMinutes","TransitFare","fareKey","fareNameFallback","fareKeyNameMap","transitFares","currentFare","name","value","currency","currencyCode","cents","TripDetails","CaloriesDetails","className","defaultFareKey","DepartureDetails","FareDetails","fareDetailsLayout","itinerary","co2Config","fareResult","calculateTncFares","maxTNCFare","minTNCFare","fare","fareDetails","details","companies","legs","forEach","leg","tncData","company","fareKeys","Object","keys","sort","length","defaultFare","TransitFareWrapper","TransitFareSingle","display","map","toLowerCase","departureDate","Date","startTime","calculatePhysicalActivity","bikeDuration","caloriesBurned","walkDuration","co2","calculateEmissions","carbonIntensity","units","containsFlex","some","isFlex","pickupBookingInfo","filter","info","dropOffBookingInfo","totalDistance","reduce","total","distance","enabled","sub","link","extraMessage","Set","message","join","Styled"],"mappings":";AAAA,OAAOA,OAAP,MAAoB,MAApB;AACA,OAAOC,SAAP,MAAsB,6BAAtB;AACA,OAAOC,KAAP,MAAoC,OAApC;AACA,SAASC,gBAAT,EAA2BC,eAA3B,QAAkD,YAAlD;AACA,SAASC,WAAT,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F;AA+ID;AAED,eAAe7D,WAAf,C,CAEA;;AACA,SAAS/B,CAAC,IAAI6F,MAAd","sourcesContent":["import flatten from \"flat\";\nimport coreUtils from \"@opentripplanner/core-utils\";\nimport React, { ReactElement } from \"react\";\nimport { FormattedMessage, FormattedNumber } from \"react-intl\";\nimport { CalendarAlt } from \"@styled-icons/fa-solid/CalendarAlt\";\nimport { Heartbeat } from \"@styled-icons/fa-solid/Heartbeat\";\nimport { MoneyBillAlt } from \"@styled-icons/fa-solid/MoneyBillAlt\";\nimport { Leaf } from \"@styled-icons/fa-solid/Leaf\";\nimport { Route } from \"@styled-icons/fa-solid/Route\";\n\nimport * as S from \"./styled\";\nimport TripDetail from \"./trip-detail\";\nimport FareLegTable from \"./fare-table\";\nimport { boldText, renderFare } from \"./utils\";\n\nimport {\n CaloriesDetailsProps,\n TransitFareProps,\n TripDetailsProps\n} from \"./types\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\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.\nconst defaultMessages: Record<string, string> = flatten(defaultEnglishMessages);\n\nconst subText = contents => <sub>{contents}</sub>;\n\n/**\n * Helper function to specify the link to dietary table.\n */\nfunction dietaryLink(contents: ReactElement): ReactElement {\n return (\n <a\n href=\"https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {contents}\n </a>\n );\n}\n\nfunction CO2DescriptionLink(contents: ReactElement): ReactElement {\n return (\n <a\n href=\"https://www.itf-oecd.org/sites/default/files/life-cycle-assessment-calculations-2020.xlsx\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {contents}\n </a>\n );\n}\n\n/**\n * Default rendering if no component is provided for the CaloriesDetails\n * slot in the TripDetails component.\n */\nfunction DefaultCaloriesDetails({\n bikeSeconds,\n calories,\n walkSeconds\n}: CaloriesDetailsProps): ReactElement {\n return (\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.caloriesDescription\"]}\n description=\"Text describing how the calories relate to the walking and biking duration of a trip.\"\n id=\"otpUi.TripDetails.caloriesDescription\"\n values={{\n bikeMinutes: Math.round(bikeSeconds / 60),\n calories: Math.round(calories),\n dietaryLink,\n strong: boldText,\n walkMinutes: Math.round(walkSeconds / 60)\n }}\n />\n );\n}\n\n/**\n * Helper component that renders a transit fare entry.\n */\nconst TransitFare = ({\n fareKey,\n fareNameFallback,\n fareKeyNameMap,\n transitFares\n}: TransitFareProps): ReactElement => {\n const currentFare = transitFares[fareKey];\n\n return (\n <span>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.transitFareEntry\"]}\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFareEntry\"\n values={{\n name: fareKeyNameMap[fareKey] || fareNameFallback || fareKey,\n strong: boldText,\n value: renderFare(\n currentFare.currency.currencyCode,\n currentFare.cents / 100\n )\n }}\n />\n </span>\n );\n};\n\n/**\n * Renders trip details such as departure instructions, fare amount, and calories spent.\n */\nexport function TripDetails({\n CaloriesDetails = DefaultCaloriesDetails,\n className = \"\",\n defaultFareKey = \"regular\",\n DepartureDetails = null,\n FareDetails = null,\n fareDetailsLayout,\n fareKeyNameMap = {},\n itinerary,\n co2Config\n}: TripDetailsProps): ReactElement {\n // process the transit fare\n const fareResult = coreUtils.itinerary.calculateTncFares(itinerary);\n const { currencyCode, maxTNCFare, minTNCFare } = fareResult;\n const transitFares = itinerary?.fare?.fare;\n const fareDetails = itinerary.fare?.details;\n\n let companies = \"\";\n itinerary.legs.forEach(leg => {\n if (leg.tncData) {\n companies = leg.tncData.company;\n }\n });\n let fare;\n\n const fareKeys = transitFares && Object.keys(transitFares).sort();\n\n if (transitFares && fareKeys.length > 0) {\n let defaultFare = defaultFareKey;\n if (!transitFares[defaultFareKey]) {\n defaultFare = \"regular\";\n }\n\n // Depending on if there are additional fares to display either render a <span> or a <details>\n const TransitFareWrapper =\n transitFares && fareKeys.length > 1 ? S.TransitFare : S.TransitFareSingle;\n\n fare = (\n <S.Fare>\n <TransitFareWrapper>\n <summary style={{ display: fareKeys.length > 1 ? \"list-item\" : \"\" }}>\n <TransitFare\n fareNameFallback={\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.transitFare\"]\n }\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFare\"\n />\n }\n fareKey={defaultFare}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n </summary>\n {fareDetailsLayout ? (\n // Show full ƒare details by leg\n <FareLegTable\n layout={fareDetailsLayout}\n legs={itinerary.legs}\n transitFareDetails={fareDetails}\n transitFares={transitFares}\n />\n ) : (\n // Just show the fares for each payment type\n fareKeys.map(fareKey => {\n // Don't show the default fare twice!\n if (fareKey === defaultFare) {\n return null;\n }\n return (\n <TransitFare\n fareKey={fareKey}\n key={fareKey}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n );\n })\n )}\n </TransitFareWrapper>\n {minTNCFare !== 0 && (\n <S.TNCFare>\n <br />\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.tncFare\"]}\n description=\"Text showing the price paid to transportation network companies.\"\n id=\"otpUi.TripDetails.tncFare\"\n values={{\n companies: (\n // S.TNCFareCompanies capitalizes the TNC company ID (e.g. \"COMPANY\")\n // after it is converted to lowercase, so it renders as \"Company\".\n <S.TNCFareCompanies>\n {companies.toLowerCase()}\n </S.TNCFareCompanies>\n ),\n maxTNCFare: renderFare(currencyCode, maxTNCFare),\n minTNCFare: renderFare(currencyCode, minTNCFare),\n strong: boldText\n }}\n />\n </S.TNCFare>\n )}\n </S.Fare>\n );\n }\n\n const departureDate = new Date(itinerary.startTime);\n\n // Compute calories burned.\n const {\n bikeDuration,\n caloriesBurned,\n walkDuration\n } = coreUtils.itinerary.calculatePhysicalActivity(itinerary);\n\n const co2 = coreUtils.itinerary.calculateEmissions(\n itinerary,\n co2Config?.carbonIntensity,\n co2Config?.units\n );\n\n // Parse flex info and generate appropriate strings\n const containsFlex = itinerary.legs.some(coreUtils.itinerary.isFlex);\n const pickupBookingInfo = itinerary.legs\n .map(leg => leg.pickupBookingInfo)\n .filter(info => !!info);\n const dropOffBookingInfo = itinerary.legs\n .map(leg => leg.dropOffBookingInfo)\n .filter(info => !!info);\n const totalDistance = itinerary.legs.reduce(\n (total, leg) => total + leg.distance,\n 0\n );\n\n return (\n <S.TripDetails className={className}>\n <S.TripDetailsHeader>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.title\"]}\n description=\"Title (heading) text of the component.\"\n id=\"otpUi.TripDetails.title\"\n />\n </S.TripDetailsHeader>\n <S.TripDetailsBody>\n <TripDetail\n // Any custom description for the Departure message needs to be handled by the slot.\n description={\n DepartureDetails && (\n <DepartureDetails departureDate={departureDate} />\n )\n }\n icon={<CalendarAlt size={17} />}\n summary={\n <S.Timing>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.departure\"]}\n description=\"Text showing the departure date/time for a trip.\"\n id=\"otpUi.TripDetails.departure\"\n values={{\n departureDate,\n strong: boldText\n }}\n />\n </S.Timing>\n }\n />\n {fare && (\n <TripDetail\n // Any custom description for the transit fare needs to be handled by the slot.\n description={\n FareDetails && (\n <FareDetails\n maxTNCFare={maxTNCFare}\n minTNCFare={minTNCFare}\n transitFares={transitFares}\n />\n )\n }\n icon={<MoneyBillAlt size={17} />}\n summary={fare}\n />\n )}\n {caloriesBurned > 0 && (\n <TripDetail\n icon={<Heartbeat size={17} />}\n summary={\n <S.CaloriesSummary>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.calories\"]}\n description=\"Text showing the number of calories for the walking and biking legs of a trip.\"\n id=\"otpUi.TripDetails.calories\"\n values={{\n calories: caloriesBurned,\n strong: boldText\n }}\n />\n </S.CaloriesSummary>\n }\n description={\n CaloriesDetails && (\n <CaloriesDetails\n bikeSeconds={bikeDuration}\n calories={caloriesBurned}\n walkSeconds={walkDuration}\n />\n )\n }\n />\n )}\n {co2 > 0 && co2Config?.enabled && (\n <TripDetail\n icon={<Leaf size={17} />}\n summary={\n <S.CO2Summary>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.co2\"]}\n description=\"Text showing the quantity of CO2 emitted by this trip.\"\n id=\"otpUi.TripDetails.co2\"\n values={{\n co2: (\n <FormattedNumber\n value={Math.round(co2)}\n // eslint-disable-next-line react/style-prop-object\n style=\"unit\"\n unit={co2Config?.units || \"gram\"}\n unitDisplay=\"narrow\"\n />\n ),\n strong: boldText,\n sub: subText\n }}\n />\n </S.CO2Summary>\n }\n description={\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.co2description\"]\n }\n values={{\n link: CO2DescriptionLink,\n sub: subText,\n totalDistance\n }}\n description=\"Text explaining how the CO2 emissions is calculated.\"\n id=\"otpUi.TripDetails.co2description\"\n />\n }\n />\n )}\n {containsFlex && (\n <TripDetail\n summary={\n <S.FlexSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.tripIncludesFlex\"]\n }\n description=\"Text stating that portions of the trip include a flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.tripIncludesFlex\"\n values={{\n extraMessage: [\n ...new Set([\n ...pickupBookingInfo.map(info => info.message),\n ...dropOffBookingInfo.map(info => info.message)\n ])\n ].join(\" \")\n }}\n />\n </S.FlexSummary>\n }\n icon={<Route size={17} />}\n />\n )}\n </S.TripDetailsBody>\n </S.TripDetails>\n );\n}\n\nexport default TripDetails;\n\n// Rename styled components for export\nexport { S as Styled };\n"],"file":"index.js"}
|
package/esm/styled.js
CHANGED
|
@@ -11,70 +11,78 @@ export var CaloriesSummary = styled.span.withConfig({
|
|
|
11
11
|
displayName: "styled__CaloriesSummary",
|
|
12
12
|
componentId: "sc-6q2ok2-2"
|
|
13
13
|
})([""]);
|
|
14
|
+
export var CO2Description = styled.span.withConfig({
|
|
15
|
+
displayName: "styled__CO2Description",
|
|
16
|
+
componentId: "sc-6q2ok2-3"
|
|
17
|
+
})([""]);
|
|
18
|
+
export var CO2Summary = styled.span.withConfig({
|
|
19
|
+
displayName: "styled__CO2Summary",
|
|
20
|
+
componentId: "sc-6q2ok2-4"
|
|
21
|
+
})([""]);
|
|
14
22
|
export var ExpandButton = styled(BaseButton).attrs({
|
|
15
23
|
"aria-label": "What does this mean?"
|
|
16
24
|
}).withConfig({
|
|
17
25
|
displayName: "styled__ExpandButton",
|
|
18
|
-
componentId: "sc-6q2ok2-
|
|
26
|
+
componentId: "sc-6q2ok2-5"
|
|
19
27
|
})(["color:#00f;font-size:16px;margin-left:6px;margin-top:-2px;"]);
|
|
20
28
|
export var Fare = styled.span.withConfig({
|
|
21
29
|
displayName: "styled__Fare",
|
|
22
|
-
componentId: "sc-6q2ok2-
|
|
30
|
+
componentId: "sc-6q2ok2-6"
|
|
23
31
|
})([""]);
|
|
24
32
|
export var HideButton = styled(BaseButton).withConfig({
|
|
25
33
|
displayName: "styled__HideButton",
|
|
26
|
-
componentId: "sc-6q2ok2-
|
|
34
|
+
componentId: "sc-6q2ok2-7"
|
|
27
35
|
})(["float:right;"]);
|
|
28
36
|
export var TNCFare = styled.span.withConfig({
|
|
29
37
|
displayName: "styled__TNCFare",
|
|
30
|
-
componentId: "sc-6q2ok2-
|
|
38
|
+
componentId: "sc-6q2ok2-8"
|
|
31
39
|
})([""]);
|
|
32
40
|
export var TNCFareCompanies = styled.span.withConfig({
|
|
33
41
|
displayName: "styled__TNCFareCompanies",
|
|
34
|
-
componentId: "sc-6q2ok2-
|
|
42
|
+
componentId: "sc-6q2ok2-9"
|
|
35
43
|
})(["text-transform:capitalize;"]);
|
|
36
44
|
export var Timing = styled.span.withConfig({
|
|
37
45
|
displayName: "styled__Timing",
|
|
38
|
-
componentId: "sc-6q2ok2-
|
|
46
|
+
componentId: "sc-6q2ok2-10"
|
|
39
47
|
})([""]);
|
|
40
48
|
export var TransitFare = styled.details.withConfig({
|
|
41
49
|
displayName: "styled__TransitFare",
|
|
42
|
-
componentId: "sc-6q2ok2-
|
|
50
|
+
componentId: "sc-6q2ok2-11"
|
|
43
51
|
})(["display:inline-block;> span{display:block;padding-left:1.75ch;}"]);
|
|
44
52
|
export var TransitFareSingle = styled.span.withConfig({
|
|
45
53
|
displayName: "styled__TransitFareSingle",
|
|
46
|
-
componentId: "sc-6q2ok2-
|
|
54
|
+
componentId: "sc-6q2ok2-12"
|
|
47
55
|
})([""]);
|
|
48
56
|
export var FlexSummary = styled.span.withConfig({
|
|
49
57
|
displayName: "styled__FlexSummary",
|
|
50
|
-
componentId: "sc-6q2ok2-
|
|
58
|
+
componentId: "sc-6q2ok2-13"
|
|
51
59
|
})([""]);
|
|
52
60
|
export var TripDetail = styled.div.withConfig({
|
|
53
61
|
displayName: "styled__TripDetail",
|
|
54
|
-
componentId: "sc-6q2ok2-
|
|
62
|
+
componentId: "sc-6q2ok2-14"
|
|
55
63
|
})(["margin-top:6px;"]);
|
|
56
64
|
export var TripDetailDescription = styled.div.withConfig({
|
|
57
65
|
displayName: "styled__TripDetailDescription",
|
|
58
|
-
componentId: "sc-6q2ok2-
|
|
66
|
+
componentId: "sc-6q2ok2-15"
|
|
59
67
|
})(["background-color:#fff;border:1px solid #888;font-size:12px;margin-top:2px;padding:8px;"]);
|
|
60
68
|
export var TripDetailIcon = styled.div.withConfig({
|
|
61
69
|
displayName: "styled__TripDetailIcon",
|
|
62
|
-
componentId: "sc-6q2ok2-
|
|
70
|
+
componentId: "sc-6q2ok2-16"
|
|
63
71
|
})(["float:left;font-size:17px;"]);
|
|
64
72
|
export var TripDetails = styled.div.withConfig({
|
|
65
73
|
displayName: "styled__TripDetails",
|
|
66
|
-
componentId: "sc-6q2ok2-
|
|
74
|
+
componentId: "sc-6q2ok2-17"
|
|
67
75
|
})(["background-color:#eee;border-radius:6px;margin-bottom:15px;margin-top:16px;padding:10px 16px;"]);
|
|
68
76
|
export var TripDetailsBody = styled.div.withConfig({
|
|
69
77
|
displayName: "styled__TripDetailsBody",
|
|
70
|
-
componentId: "sc-6q2ok2-
|
|
78
|
+
componentId: "sc-6q2ok2-18"
|
|
71
79
|
})([""]);
|
|
72
80
|
export var TripDetailsHeader = styled.div.withConfig({
|
|
73
81
|
displayName: "styled__TripDetailsHeader",
|
|
74
|
-
componentId: "sc-6q2ok2-
|
|
82
|
+
componentId: "sc-6q2ok2-19"
|
|
75
83
|
})(["font-size:18px;font-weight:600;"]);
|
|
76
84
|
export var TripDetailSummary = styled.div.withConfig({
|
|
77
85
|
displayName: "styled__TripDetailSummary",
|
|
78
|
-
componentId: "sc-6q2ok2-
|
|
86
|
+
componentId: "sc-6q2ok2-20"
|
|
79
87
|
})(["margin-left:28px;padding-top:2px;display:flex;align-items:baseline;"]);
|
|
80
88
|
//# sourceMappingURL=styled.js.map
|
package/esm/styled.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/styled.ts"],"names":["styled","BaseButton","button","CaloriesDescription","span","CaloriesSummary","ExpandButton","attrs","Fare","HideButton","TNCFare","TNCFareCompanies","Timing","TransitFare","details","TransitFareSingle","FlexSummary","TripDetail","div","TripDetailDescription","TripDetailIcon","TripDetails","TripDetailsBody","TripDetailsHeader","TripDetailSummary"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,mBAAnB;AAEA,IAAMC,UAAU,GAAGD,MAAM,CAACE,MAAV;AAAA;AAAA;AAAA,8PAAhB;AAiBA,OAAO,IAAMC,mBAAmB,GAAGH,MAAM,CAACI,IAAV;AAAA;AAAA;AAAA,QAAzB;AAEP,OAAO,IAAMC,eAAe,GAAGL,MAAM,CAACI,IAAV;AAAA;AAAA;AAAA,QAArB;AAEP,OAAO,IAAME,
|
|
1
|
+
{"version":3,"sources":["../src/styled.ts"],"names":["styled","BaseButton","button","CaloriesDescription","span","CaloriesSummary","CO2Description","CO2Summary","ExpandButton","attrs","Fare","HideButton","TNCFare","TNCFareCompanies","Timing","TransitFare","details","TransitFareSingle","FlexSummary","TripDetail","div","TripDetailDescription","TripDetailIcon","TripDetails","TripDetailsBody","TripDetailsHeader","TripDetailSummary"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,mBAAnB;AAEA,IAAMC,UAAU,GAAGD,MAAM,CAACE,MAAV;AAAA;AAAA;AAAA,8PAAhB;AAiBA,OAAO,IAAMC,mBAAmB,GAAGH,MAAM,CAACI,IAAV;AAAA;AAAA;AAAA,QAAzB;AAEP,OAAO,IAAMC,eAAe,GAAGL,MAAM,CAACI,IAAV;AAAA;AAAA;AAAA,QAArB;AAEP,OAAO,IAAME,cAAc,GAAGN,MAAM,CAACI,IAAV;AAAA;AAAA;AAAA,QAApB;AAEP,OAAO,IAAMG,UAAU,GAAGP,MAAM,CAACI,IAAV;AAAA;AAAA;AAAA,QAAhB;AAEP,OAAO,IAAMI,YAAY,GAAGR,MAAM,CAACC,UAAD,CAAN,CAAmBQ,KAAnB,CAAyB;AACnD,gBAAc;AADqC,CAAzB,CAAH;AAAA;AAAA;AAAA,kEAAlB;AASP,OAAO,IAAMC,IAAI,GAAGV,MAAM,CAACI,IAAV;AAAA;AAAA;AAAA,QAAV;AAEP,OAAO,IAAMO,UAAU,GAAGX,MAAM,CAACC,UAAD,CAAT;AAAA;AAAA;AAAA,oBAAhB;AAIP,OAAO,IAAMW,OAAO,GAAGZ,MAAM,CAACI,IAAV;AAAA;AAAA;AAAA,QAAb;AAEP,OAAO,IAAMS,gBAAgB,GAAGb,MAAM,CAACI,IAAV;AAAA;AAAA;AAAA,kCAAtB;AAIP,OAAO,IAAMU,MAAM,GAAGd,MAAM,CAACI,IAAV;AAAA;AAAA;AAAA,QAAZ;AAEP,OAAO,IAAMW,WAAW,GAAGf,MAAM,CAACgB,OAAV;AAAA;AAAA;AAAA,uEAAjB;AAUP,OAAO,IAAMC,iBAAiB,GAAGjB,MAAM,CAACI,IAAV;AAAA;AAAA;AAAA,QAAvB;AAEP,OAAO,IAAMc,WAAW,GAAGlB,MAAM,CAACI,IAAV;AAAA;AAAA;AAAA,QAAjB;AAEP,OAAO,IAAMe,UAAU,GAAGnB,MAAM,CAACoB,GAAV;AAAA;AAAA;AAAA,uBAAhB;AAIP,OAAO,IAAMC,qBAAqB,GAAGrB,MAAM,CAACoB,GAAV;AAAA;AAAA;AAAA,8FAA3B;AAQP,OAAO,IAAME,cAAc,GAAGtB,MAAM,CAACoB,GAAV;AAAA;AAAA;AAAA,kCAApB;AAKP,OAAO,IAAMG,WAAW,GAAGvB,MAAM,CAACoB,GAAV;AAAA;AAAA;AAAA,qGAAjB;AAQP,OAAO,IAAMI,eAAe,GAAGxB,MAAM,CAACoB,GAAV;AAAA;AAAA;AAAA,QAArB;AAEP,OAAO,IAAMK,iBAAiB,GAAGzB,MAAM,CAACoB,GAAV;AAAA;AAAA;AAAA,uCAAvB;AAKP,OAAO,IAAMM,iBAAiB,GAAG1B,MAAM,CAACoB,GAAV;AAAA;AAAA;AAAA,2EAAvB","sourcesContent":["import styled from \"styled-components\";\n\nconst BaseButton = styled.button`\n background: transparent;\n border: 0;\n cursor: pointer;\n display: inline-block;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n margin: 0;\n padding: 0;\n text-decoration: none;\n touch-action: manipulation;\n user-select: none;\n vertical-align: middle;\n white-space: nowrap;\n`;\n\nexport const CaloriesDescription = styled.span``;\n\nexport const CaloriesSummary = styled.span``;\n\nexport const CO2Description = styled.span``;\n\nexport const CO2Summary = styled.span``;\n\nexport const ExpandButton = styled(BaseButton).attrs({\n \"aria-label\": \"What does this mean?\"\n})`\n color: #00f;\n font-size: 16px;\n margin-left: 6px;\n margin-top: -2px;\n`;\n\nexport const Fare = styled.span``;\n\nexport const HideButton = styled(BaseButton)`\n float: right;\n`;\n\nexport const TNCFare = styled.span``;\n\nexport const TNCFareCompanies = styled.span`\n text-transform: capitalize;\n`;\n\nexport const Timing = styled.span``;\n\nexport const TransitFare = styled.details`\n display: inline-block;\n\n > span {\n display: block;\n /* This may seem wrong, but this value gives the most aligned results */\n /* see: https://github.com/opentripplanner/otp-ui/pull/294#discussion_r742045851 */\n padding-left: 1.75ch;\n }\n`;\nexport const TransitFareSingle = styled.span``;\n\nexport const FlexSummary = styled.span``;\n\nexport const TripDetail = styled.div`\n margin-top: 6px;\n`;\n\nexport const TripDetailDescription = styled.div`\n background-color: #fff;\n border: 1px solid #888;\n font-size: 12px;\n margin-top: 2px;\n padding: 8px;\n`;\n\nexport const TripDetailIcon = styled.div`\n float: left;\n font-size: 17px;\n`;\n\nexport const TripDetails = styled.div`\n background-color: #eee;\n border-radius: 6px;\n margin-bottom: 15px;\n margin-top: 16px;\n padding: 10px 16px;\n`;\n\nexport const TripDetailsBody = styled.div``;\n\nexport const TripDetailsHeader = styled.div`\n font-size: 18px;\n font-weight: 600;\n`;\n\nexport const TripDetailSummary = styled.div`\n margin-left: 28px;\n padding-top: 2px;\n display: flex;\n align-items: baseline;\n`;\n"],"file":"styled.js"}
|
package/esm/trip-detail.js
CHANGED
|
@@ -11,7 +11,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
11
11
|
import React, { Component } from "react";
|
|
12
12
|
import { QuestionCircle } from "@styled-icons/fa-solid/QuestionCircle";
|
|
13
13
|
import { TimesCircle } from "@styled-icons/fa-solid/TimesCircle";
|
|
14
|
-
import
|
|
14
|
+
import AnimateHeight from "react-animate-height";
|
|
15
15
|
import * as S from "./styled";
|
|
16
16
|
|
|
17
17
|
var TripDetail = /*#__PURE__*/function (_Component) {
|
|
@@ -61,14 +61,10 @@ var TripDetail = /*#__PURE__*/function (_Component) {
|
|
|
61
61
|
onClick: this.toggle
|
|
62
62
|
}, /*#__PURE__*/React.createElement(QuestionCircle, {
|
|
63
63
|
size: "0.92em"
|
|
64
|
-
}))), /*#__PURE__*/React.createElement(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
leave: {
|
|
69
|
-
animation: "slideUp"
|
|
70
|
-
}
|
|
71
|
-
}, expanded && /*#__PURE__*/React.createElement(S.TripDetailDescription, null, /*#__PURE__*/React.createElement(S.HideButton, {
|
|
64
|
+
}))), /*#__PURE__*/React.createElement(AnimateHeight, {
|
|
65
|
+
duration: 300,
|
|
66
|
+
height: expanded ? "auto" : 0
|
|
67
|
+
}, /*#__PURE__*/React.createElement(S.TripDetailDescription, null, /*#__PURE__*/React.createElement(S.HideButton, {
|
|
72
68
|
onClick: this.onHideClick
|
|
73
69
|
}, /*#__PURE__*/React.createElement(TimesCircle, {
|
|
74
70
|
size: "0.92em"
|
package/esm/trip-detail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/trip-detail.tsx"],"names":["React","Component","QuestionCircle","TimesCircle","
|
|
1
|
+
{"version":3,"sources":["../src/trip-detail.tsx"],"names":["React","Component","QuestionCircle","TimesCircle","AnimateHeight","S","TripDetail","props","toggle","expanded","state","onHideClick","onExpandClick","setState","icon","summary","description"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAA+C,OAA/C;AACA,SAASC,cAAT,QAA+B,uCAA/B;AACA,SAASC,WAAT,QAA4B,oCAA5B;AAEA,OAAOC,aAAP,MAA0B,sBAA1B;AACA,OAAO,KAAKC,CAAZ,MAAmB,UAAnB;;IAYqBC,U;;;;;AACnB,sBAAYC,KAAZ,EAA0B;AAAA;;AAAA;;AACxB,8BAAMA,KAAN;;AADwB,UAO1BC,MAP0B,GAOjB,YAAY;AACnB,UAAQC,QAAR,GAAqB,MAAKC,KAA1B,CAAQD,QAAR;AACA,UAAIA,QAAJ,EAAc,MAAKE,WAAL,GAAd,KACK,MAAKC,aAAL;AACN,KAXyB;;AAAA,UAa1BA,aAb0B,GAaV,YAAY;AAC1B,YAAKC,QAAL,CAAc;AAAEJ,QAAAA,QAAQ,EAAE;AAAZ,OAAd;AACD,KAfyB;;AAAA,UAiB1BE,WAjB0B,GAiBZ,YAAY;AACxB,YAAKE,QAAL,CAAc;AAAEJ,QAAAA,QAAQ,EAAE;AAAZ,OAAd;AACD,KAnByB;;AAExB,UAAKC,KAAL,GAAa;AACXD,MAAAA,QAAQ,EAAE;AADC,KAAb;AAFwB;AAKzB;;;;WAgBD,kBAAuB;AACrB,wBAAuC,KAAKF,KAA5C;AAAA,UAAQO,IAAR,eAAQA,IAAR;AAAA,UAAcC,OAAd,eAAcA,OAAd;AAAA,UAAuBC,WAAvB,eAAuBA,WAAvB;AACA,UAAQP,QAAR,GAAqB,KAAKC,KAA1B,CAAQD,QAAR;AACA,0BACE,oBAAC,CAAD,CAAG,UAAH,qBACE,oBAAC,CAAD,CAAG,cAAH,QAAmBK,IAAnB,CADF,eAEE,oBAAC,CAAD,CAAG,iBAAH,QACGC,OADH,EAEGC,WAAW,iBACV,oBAAC,CAAD,CAAG,YAAH;AAAgB,QAAA,OAAO,EAAE,KAAKR;AAA9B,sBACE,oBAAC,cAAD;AAAgB,QAAA,IAAI,EAAC;AAArB,QADF,CAHJ,CAFF,eAUE,oBAAC,aAAD;AAAe,QAAA,QAAQ,EAAE,GAAzB;AAA8B,QAAA,MAAM,EAAEC,QAAQ,GAAG,MAAH,GAAY;AAA1D,sBACE,oBAAC,CAAD,CAAG,qBAAH,qBACE,oBAAC,CAAD,CAAG,UAAH;AAAc,QAAA,OAAO,EAAE,KAAKE;AAA5B,sBACE,oBAAC,WAAD;AAAa,QAAA,IAAI,EAAC;AAAlB,QADF,CADF,EAIGK,WAJH,CADF,CAVF,CADF;AAqBD;;;;EA9CqCf,S;;SAAnBK,U","sourcesContent":["import React, { Component, ReactElement } from \"react\";\nimport { QuestionCircle } from \"@styled-icons/fa-solid/QuestionCircle\";\nimport { TimesCircle } from \"@styled-icons/fa-solid/TimesCircle\";\n\nimport AnimateHeight from \"react-animate-height\";\nimport * as S from \"./styled\";\n\ntype Props = {\n description?: ReactElement | string;\n icon: ReactElement;\n summary: ReactElement | string;\n};\n\ntype State = {\n expanded: boolean;\n};\n\nexport default class TripDetail extends Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = {\n expanded: false\n };\n }\n\n toggle = (): void => {\n const { expanded } = this.state;\n if (expanded) this.onHideClick();\n else this.onExpandClick();\n };\n\n onExpandClick = (): void => {\n this.setState({ expanded: true });\n };\n\n onHideClick = (): void => {\n this.setState({ expanded: false });\n };\n\n render(): ReactElement {\n const { icon, summary, description } = this.props;\n const { expanded } = this.state;\n return (\n <S.TripDetail>\n <S.TripDetailIcon>{icon}</S.TripDetailIcon>\n <S.TripDetailSummary>\n {summary}\n {description && (\n <S.ExpandButton onClick={this.toggle}>\n <QuestionCircle size=\"0.92em\" />\n </S.ExpandButton>\n )}\n </S.TripDetailSummary>\n <AnimateHeight duration={300} height={expanded ? \"auto\" : 0}>\n <S.TripDetailDescription>\n <S.HideButton onClick={this.onHideClick}>\n <TimesCircle size=\"0.92em\" />\n </S.HideButton>\n {description}\n </S.TripDetailDescription>\n </AnimateHeight>\n </S.TripDetail>\n );\n }\n}\n"],"file":"trip-detail.js"}
|
package/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"names":["FareTableText"],"mappings":"AAAA;AACA;
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"names":["FareTableText"],"mappings":"AAAA;AACA;AAoBA,WAAYA,aAAZ;;WAAYA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,KAAAA,a","sourcesContent":["// Prettier does not recognize the import type syntax.\n// eslint-disable-next-line prettier/prettier\nimport type { FareDetails, Money, Itinerary, Leg, Fare, } from \"@opentripplanner/types\";\nimport type { ReactElement } from \"react\";\n\nexport interface CaloriesDetailsProps {\n bikeSeconds: number;\n calories: number;\n walkSeconds: number;\n}\n\nexport interface CO2ConfigType {\n carbonIntensity?: { [index: string]: number };\n units?: string;\n enabled?: boolean;\n}\n\nexport interface DepartureDetailsProps {\n departureDate: Date;\n}\n\nexport enum FareTableText {\n regular = \"regular\",\n youth = \"youth\",\n senior = \"senior\",\n special = \"special\",\n cash = \"cash\",\n electronic = \"electronic\"\n}\n\nexport interface FareTableLayout {\n cols: {\n header: FareTableText;\n key: string;\n }[];\n header: FareTableText;\n}\nexport interface TransitFareData {\n [key: string]: Money\n}\n\nexport interface FareDetailsProps {\n maxTNCFare: number;\n minTNCFare: number;\n transitFares: TransitFareData;\n}\n\nexport interface FareLegTableProps {\n layout?: FareTableLayout[];\n legs?: Leg[];\n transitFareDetails?: FareDetails;\n transitFares?: TransitFareData;\n}\n\nexport interface TransitFareProps {\n fareKey: string;\n fareNameFallback?: ReactElement;\n fareKeyNameMap: {\n [key: string]: string;\n };\n transitFares: Fare;\n}\n\nexport interface TripDetailsProps {\n /**\n * Slot for a custom component to render the expandable section for calories.\n */\n CaloriesDetails?: React.ElementType<CaloriesDetailsProps>;\n /**\n * Used for additional styling with styled components for example.\n */\n className?: string;\n /**\n * Determines which transit fare should be displayed by default, should there be multiple transit fare types.\n */\n defaultFareKey?: string;\n /**\n * Slot for a custom component to render the expandable section for departure.\n */\n DepartureDetails?: React.ElementType<DepartureDetailsProps>;\n /**\n * Slot for a custom component to render the expandable section for fares.\n */\n FareDetails?: React.ElementType<FareDetailsProps>;\n /**\n * Column and table configuration for fare details/fare by leg table.\n */\n fareDetailsLayout?: FareTableLayout[];\n /**\n * Mapping between fare keys and human-readable names for them.\n */\n fareKeyNameMap?: {\n [name: string]: string;\n };\n /**\n * Itinerary that the user has selected to view, contains multiple legs.\n */\n itinerary: Itinerary;\n /**\n * Object containing the CO2 config.\n */\n co2Config?: CO2ConfigType;\n}\n"],"file":"types.js"}
|
package/i18n/en-US.yml
CHANGED
|
@@ -19,6 +19,10 @@ otpUi:
|
|
|
19
19
|
<strong>{walkMinutes, plural, one {# minute} other {# minutes}}</strong> spent walking and
|
|
20
20
|
<strong>{bikeMinutes, plural, one {# minute} other {# minutes}}</strong> spent biking during this trip.
|
|
21
21
|
Adapted from <dietaryLink>Dietary Guidelines for Americans 2005, page 16, Table 4</dietaryLink>.
|
|
22
|
+
co2: "CO<sub>2</sub> Emitted: <strong>{co2}</strong>"
|
|
23
|
+
co2description:
|
|
24
|
+
"CO<sub>2</sub> intensity is calculated by multiplying the distance of each leg of a trip by the CO<sub>2</sub> intensity of each mode.
|
|
25
|
+
CO<sub>2</sub> intensity of each mode is derived from <link>this spreadsheet</link>."
|
|
22
26
|
departure: Depart <strong>{departureDate, date, long}</strong> at <strong>{departureDate, time, short}</strong>
|
|
23
27
|
title: Trip Details
|
|
24
28
|
tncFare: "{companies} Fare: <strong>{minTNCFare} - {maxTNCFare}</strong>"
|
package/i18n/fr.yml
CHANGED
|
@@ -7,6 +7,10 @@ otpUi:
|
|
|
7
7
|
{walkMinutes, plural, one {<strong># minute</strong> effectuée} other {<strong># minutes</strong> effectuées}} à pied et
|
|
8
8
|
{bikeMinutes, plural, one {<strong># minute</strong> effectuée} other {<strong># minutes</strong> effectuées}} en vélo sur ce trajet.
|
|
9
9
|
(d'après <dietaryLink>Dietary Guidelines for Americans 2005, page 16, Table 4</dietaryLink>)
|
|
10
|
+
co2: "CO<sub>2</sub> émis: <strong>{co2}</strong>"
|
|
11
|
+
co2description:
|
|
12
|
+
"L'intensité carbone est calculée en multipliant la distance de chaque portion d'un trajet par l'intensité en CO<sub>2</sub> du mode utilisé.
|
|
13
|
+
L'intensité en CO<sub>2</sub> de chaque mode est obtenue d'après <link>ce tableau</link>."
|
|
10
14
|
departure: Départ le <strong>{departureDate, date, long}</strong> à <strong>{departureDate, time, short}</strong>
|
|
11
15
|
title: Détails du trajet
|
|
12
16
|
tncFare: "Tarif {companies} : <strong>{minTNCFare} - {maxTNCFare}</strong>"
|
package/lib/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { TripDetailsProps } from "./types";
|
|
|
4
4
|
/**
|
|
5
5
|
* Renders trip details such as departure instructions, fare amount, and calories spent.
|
|
6
6
|
*/
|
|
7
|
-
export declare function TripDetails({ CaloriesDetails, className, defaultFareKey, DepartureDetails, FareDetails, fareDetailsLayout, fareKeyNameMap, itinerary }: TripDetailsProps): ReactElement;
|
|
7
|
+
export declare function TripDetails({ CaloriesDetails, className, defaultFareKey, DepartureDetails, FareDetails, fareDetailsLayout, fareKeyNameMap, itinerary, co2Config }: TripDetailsProps): ReactElement;
|
|
8
8
|
export default TripDetails;
|
|
9
9
|
export { S as Styled };
|
|
10
10
|
//# 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":"AAEA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAQ5C,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAK9B,OAAO,EAGL,gBAAgB,EACjB,MAAM,SAAS,CAAC;AA+FjB;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAC1B,eAAwC,EACxC,SAAc,EACd,cAA0B,EAC1B,gBAAuB,EACvB,WAAkB,EAClB,iBAAiB,EACjB,cAAmB,EACnB,SAAS,EACT,SAAS,EACV,EAAE,gBAAgB,GAAG,YAAY,CA6QjC;AAED,eAAe,WAAW,CAAC;AAG3B,OAAO,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -22,6 +22,8 @@ var _Heartbeat = require("@styled-icons/fa-solid/Heartbeat");
|
|
|
22
22
|
|
|
23
23
|
var _MoneyBillAlt = require("@styled-icons/fa-solid/MoneyBillAlt");
|
|
24
24
|
|
|
25
|
+
var _Leaf = require("@styled-icons/fa-solid/Leaf");
|
|
26
|
+
|
|
25
27
|
var _Route = require("@styled-icons/fa-solid/Route");
|
|
26
28
|
|
|
27
29
|
var S = _interopRequireWildcard(require("./styled"));
|
|
@@ -46,10 +48,13 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
46
48
|
// - the yaml loader for webpack returns a nested object,
|
|
47
49
|
// - the yaml loader for jest returns messages with flattened ids.
|
|
48
50
|
const defaultMessages = (0, _flat.default)(_enUS.default);
|
|
51
|
+
|
|
52
|
+
const subText = contents => /*#__PURE__*/_react.default.createElement("sub", null, contents);
|
|
49
53
|
/**
|
|
50
54
|
* Helper function to specify the link to dietary table.
|
|
51
55
|
*/
|
|
52
56
|
|
|
57
|
+
|
|
53
58
|
function dietaryLink(contents) {
|
|
54
59
|
return /*#__PURE__*/_react.default.createElement("a", {
|
|
55
60
|
href: "https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4",
|
|
@@ -57,6 +62,14 @@ function dietaryLink(contents) {
|
|
|
57
62
|
target: "_blank"
|
|
58
63
|
}, contents);
|
|
59
64
|
}
|
|
65
|
+
|
|
66
|
+
function CO2DescriptionLink(contents) {
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement("a", {
|
|
68
|
+
href: "https://www.itf-oecd.org/sites/default/files/life-cycle-assessment-calculations-2020.xlsx",
|
|
69
|
+
rel: "noopener noreferrer",
|
|
70
|
+
target: "_blank"
|
|
71
|
+
}, contents);
|
|
72
|
+
}
|
|
60
73
|
/**
|
|
61
74
|
* Default rendering if no component is provided for the CaloriesDetails
|
|
62
75
|
* slot in the TripDetails component.
|
|
@@ -117,7 +130,8 @@ function TripDetails({
|
|
|
117
130
|
FareDetails = null,
|
|
118
131
|
fareDetailsLayout,
|
|
119
132
|
fareKeyNameMap = {},
|
|
120
|
-
itinerary
|
|
133
|
+
itinerary,
|
|
134
|
+
co2Config
|
|
121
135
|
}) {
|
|
122
136
|
var _itinerary$fare, _itinerary$fare2;
|
|
123
137
|
|
|
@@ -206,12 +220,15 @@ function TripDetails({
|
|
|
206
220
|
bikeDuration,
|
|
207
221
|
caloriesBurned,
|
|
208
222
|
walkDuration
|
|
209
|
-
} = _coreUtils.default.itinerary.calculatePhysicalActivity(itinerary);
|
|
223
|
+
} = _coreUtils.default.itinerary.calculatePhysicalActivity(itinerary);
|
|
224
|
+
|
|
225
|
+
const co2 = _coreUtils.default.itinerary.calculateEmissions(itinerary, co2Config === null || co2Config === void 0 ? void 0 : co2Config.carbonIntensity, co2Config === null || co2Config === void 0 ? void 0 : co2Config.units); // Parse flex info and generate appropriate strings
|
|
210
226
|
|
|
211
227
|
|
|
212
228
|
const containsFlex = itinerary.legs.some(_coreUtils.default.itinerary.isFlex);
|
|
213
229
|
const pickupBookingInfo = itinerary.legs.map(leg => leg.pickupBookingInfo).filter(info => !!info);
|
|
214
230
|
const dropOffBookingInfo = itinerary.legs.map(leg => leg.dropOffBookingInfo).filter(info => !!info);
|
|
231
|
+
const totalDistance = itinerary.legs.reduce((total, leg) => total + leg.distance, 0);
|
|
215
232
|
return /*#__PURE__*/_react.default.createElement(S.TripDetails, {
|
|
216
233
|
className: className
|
|
217
234
|
}, /*#__PURE__*/_react.default.createElement(S.TripDetailsHeader, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
|
|
@@ -264,6 +281,36 @@ function TripDetails({
|
|
|
264
281
|
calories: caloriesBurned,
|
|
265
282
|
walkSeconds: walkDuration
|
|
266
283
|
})
|
|
284
|
+
}), co2 > 0 && (co2Config === null || co2Config === void 0 ? void 0 : co2Config.enabled) && /*#__PURE__*/_react.default.createElement(_tripDetail.default, {
|
|
285
|
+
icon: /*#__PURE__*/_react.default.createElement(_Leaf.Leaf, {
|
|
286
|
+
size: 17
|
|
287
|
+
}),
|
|
288
|
+
summary: /*#__PURE__*/_react.default.createElement(S.CO2Summary, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
|
|
289
|
+
defaultMessage: defaultMessages["otpUi.TripDetails.co2"],
|
|
290
|
+
description: "Text showing the quantity of CO2 emitted by this trip.",
|
|
291
|
+
id: "otpUi.TripDetails.co2",
|
|
292
|
+
values: {
|
|
293
|
+
co2: /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedNumber, {
|
|
294
|
+
value: Math.round(co2) // eslint-disable-next-line react/style-prop-object
|
|
295
|
+
,
|
|
296
|
+
style: "unit",
|
|
297
|
+
unit: (co2Config === null || co2Config === void 0 ? void 0 : co2Config.units) || "gram",
|
|
298
|
+
unitDisplay: "narrow"
|
|
299
|
+
}),
|
|
300
|
+
strong: _utils.boldText,
|
|
301
|
+
sub: subText
|
|
302
|
+
}
|
|
303
|
+
})),
|
|
304
|
+
description: /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
|
|
305
|
+
defaultMessage: defaultMessages["otpUi.TripDetails.co2description"],
|
|
306
|
+
values: {
|
|
307
|
+
link: CO2DescriptionLink,
|
|
308
|
+
sub: subText,
|
|
309
|
+
totalDistance
|
|
310
|
+
},
|
|
311
|
+
description: "Text explaining how the CO2 emissions is calculated.",
|
|
312
|
+
id: "otpUi.TripDetails.co2description"
|
|
313
|
+
})
|
|
267
314
|
}), containsFlex && /*#__PURE__*/_react.default.createElement(_tripDetail.default, {
|
|
268
315
|
summary: /*#__PURE__*/_react.default.createElement(S.FlexSummary, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
|
|
269
316
|
defaultMessage: defaultMessages["otpUi.TripDetails.tripIncludesFlex"],
|