@opentripplanner/trip-details 1.5.0 → 2.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.
@@ -0,0 +1,7 @@
1
+ # Example used to overwrite a subset of the messages from /i18n/en-US.yml.
2
+ otpUi:
3
+ TripDetails:
4
+ caloriesDescription: "Walking <strong>{walkMinutes}</strong> minute(s) and biking <strong>{bikeMinutes}</strong> minute(s) will consume {calories} Calories."
5
+ departure: "<strong>Leave</strong> at <strong>{departureDate, time, short}</strong> on <strong>{departureDate, date, long}</strong>"
6
+ title: "Custom Trip Details Title"
7
+ tncFare: "Pay <strong>{minTNCFare}-{maxTNCFare}</strong> to {companies}"
package/esm/index.js CHANGED
@@ -1,60 +1,152 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
+ import flatten from "flat"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-ignore FIXME: Create TypeScript types for core-utils packages.
3
+
2
4
  import coreUtils from "@opentripplanner/core-utils";
3
- import moment from "moment";
4
- import PropTypes from "prop-types";
5
5
  import React from "react";
6
+ import { FormattedMessage, FormattedNumber } from "react-intl";
6
7
  import { CalendarAlt } from "@styled-icons/fa-solid/CalendarAlt";
8
+ import { HandPaper } from "@styled-icons/fa-solid/HandPaper";
7
9
  import { Heartbeat } from "@styled-icons/fa-solid/Heartbeat";
8
10
  import { MoneyBillAlt } from "@styled-icons/fa-solid/MoneyBillAlt";
11
+ import { PhoneVolume } from "@styled-icons/fa-solid/PhoneVolume";
12
+ import { Route } from "@styled-icons/fa-solid/Route";
9
13
  import * as S from "./styled";
10
14
  import TripDetail from "./trip-detail";
15
+ // Load the default messages.
16
+ import defaultEnglishMessages from "../i18n/en-US.yml"; // HACK: We should flatten the messages loaded above because
17
+ // the YAML loaders behave differently between webpack and our version of jest:
18
+ // - the yaml loader for webpack returns a nested object,
19
+ // - the yaml loader for jest returns messages with flattened ids.
20
+
21
+ var defaultMessages = flatten(defaultEnglishMessages);
22
+ /**
23
+ * Format text bold (used with FormattedMessage).
24
+ */
25
+ // TODO: Find a better place for this utility.
26
+
27
+ function boldText(contents) {
28
+ return /*#__PURE__*/React.createElement("strong", null, contents);
29
+ }
30
+ /**
31
+ * Render formatted fare.
32
+ * @param currencyCode The ISO currency code to use (USD, GBP, EUR).
33
+ * @param fare The fare value, in currency units, to be shown.
34
+ * @returns The formatted fare value according to the selected locale.
35
+ */
36
+
37
+
38
+ function renderFare(currencyCode, fare) {
39
+ return /*#__PURE__*/React.createElement(FormattedNumber, {
40
+ currency: currencyCode // For dollars in locales such as 'fr',
41
+ // this will limit the display to just the dollar sign
42
+ // (otherwise it will render e.g. '2,50 $US' instead of '2,50 $').
43
+ ,
44
+ currencyDisplay: "narrowSymbol",
45
+ value: fare // eslint-disable-next-line react/style-prop-object
46
+ ,
47
+ style: "currency"
48
+ });
49
+ }
50
+ /**
51
+ * Helper function to specify the link to dietary table.
52
+ */
53
+
54
+
55
+ function dietaryLink(contents) {
56
+ return /*#__PURE__*/React.createElement("a", {
57
+ href: "https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4",
58
+ rel: "noopener noreferrer",
59
+ target: "_blank"
60
+ }, contents);
61
+ }
62
+ /**
63
+ * Helper function that assembles values for flex pickup/dropoff messages.
64
+ */
11
65
 
12
- var TransitFare = function TransitFare(_ref) {
13
- var fareKey = _ref.fareKey,
14
- fareNameFallback = _ref.fareNameFallback,
15
- fareKeyNameMap = _ref.fareKeyNameMap,
16
- transitFares = _ref.transitFares;
66
+
67
+ function getFlexMessageValues(info) {
68
+ var _info$contactInfo, _info$contactInfo2;
69
+
70
+ return {
71
+ hasLeadTime: coreUtils.itinerary.isAdvanceBookingRequired(info),
72
+ hasPhone: !!(info !== null && info !== void 0 && (_info$contactInfo = info.contactInfo) !== null && _info$contactInfo !== void 0 && _info$contactInfo.phoneNumber),
73
+ leadDays: info.latestBookingTime.daysPrior,
74
+ phoneNumber: info === null || info === void 0 ? void 0 : (_info$contactInfo2 = info.contactInfo) === null || _info$contactInfo2 === void 0 ? void 0 : _info$contactInfo2.phoneNumber
75
+ };
76
+ }
77
+ /**
78
+ * Default rendering if no component is provided for the CaloriesDetails
79
+ * slot in the TripDetails component.
80
+ */
81
+
82
+
83
+ function DefaultCaloriesDetails(_ref) {
84
+ var bikeSeconds = _ref.bikeSeconds,
85
+ calories = _ref.calories,
86
+ walkSeconds = _ref.walkSeconds;
87
+ return /*#__PURE__*/React.createElement(FormattedMessage, {
88
+ defaultMessage: defaultMessages["otpUi.TripDetails.caloriesDescription"],
89
+ description: "Text describing how the calories relate to the walking and biking duration of a trip.",
90
+ id: "otpUi.TripDetails.caloriesDescription",
91
+ values: {
92
+ bikeMinutes: Math.round(bikeSeconds / 60),
93
+ calories: Math.round(calories),
94
+ dietaryLink: dietaryLink,
95
+ strong: boldText,
96
+ walkMinutes: Math.round(walkSeconds / 60)
97
+ }
98
+ });
99
+ }
100
+ /**
101
+ * Helper component that renders a transit fare entry.
102
+ */
103
+
104
+
105
+ var TransitFare = function TransitFare(_ref2) {
106
+ var fareKey = _ref2.fareKey,
107
+ fareNameFallback = _ref2.fareNameFallback,
108
+ fareKeyNameMap = _ref2.fareKeyNameMap,
109
+ transitFares = _ref2.transitFares;
17
110
  var currentFare = transitFares[fareKey];
18
- return /*#__PURE__*/React.createElement("span", null, fareKeyNameMap[fareKey] || fareNameFallback || fareKey, ":", " ", /*#__PURE__*/React.createElement("b", null, currentFare.centsToString(currentFare.transitFare)));
111
+ return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(FormattedMessage, {
112
+ defaultMessage: defaultMessages["otpUi.TripDetails.transitFareEntry"],
113
+ description: "Text showing the price of tickets on public transportation.",
114
+ id: "otpUi.TripDetails.transitFareEntry",
115
+ values: {
116
+ name: fareKeyNameMap[fareKey] || fareNameFallback || fareKey,
117
+ strong: boldText,
118
+ value: renderFare(currentFare.currency.currencyCode, currentFare.cents / 100)
119
+ }
120
+ }));
19
121
  };
122
+ /**
123
+ * Renders trip details such as departure instructions, fare amount, and calories spent.
124
+ */
20
125
 
21
- TransitFare.propTypes = {
22
- fareKey: PropTypes.string.isRequired,
23
- fareNameFallback: PropTypes.string,
24
- fareKeyNameMap: PropTypes.shape(_defineProperty({}, PropTypes.string, PropTypes.string)).isRequired,
25
- transitFares: PropTypes.shape({
26
- centsToString: PropTypes.func,
27
- transitFare: PropTypes.number
28
- }).isRequired
29
- };
30
- TransitFare.defaultProps = {
31
- fareNameFallback: undefined
32
- };
33
126
 
34
- function TripDetails(_ref2) {
35
- var className = _ref2.className,
36
- defaultFareKey = _ref2.defaultFareKey,
37
- itinerary = _ref2.itinerary,
38
- fareKeyNameMap = _ref2.fareKeyNameMap,
39
- longDateFormat = _ref2.longDateFormat,
40
- messages = _ref2.messages,
41
- routingType = _ref2.routingType,
42
- timeOptions = _ref2.timeOptions;
43
- var date = moment(itinerary.startTime);
44
- messages = coreUtils.messages.mergeMessages(TripDetails.defaultProps.messages, messages); // process the transit fare
45
-
46
- var _coreUtils$itinerary$ = coreUtils.itinerary.calculateFares(itinerary, true),
47
- maxTNCFare = _coreUtils$itinerary$.maxTNCFare,
48
- minTNCFare = _coreUtils$itinerary$.minTNCFare,
49
- transitFares = _coreUtils$itinerary$.transitFares;
50
-
51
- var defaultFare = defaultFareKey;
52
-
53
- if (!transitFares[defaultFareKey]) {
54
- defaultFare = "regular";
55
- }
127
+ export function TripDetails(_ref3) {
128
+ var _itinerary$fare;
56
129
 
57
- var companies;
130
+ var _ref3$CaloriesDetails = _ref3.CaloriesDetails,
131
+ CaloriesDetails = _ref3$CaloriesDetails === void 0 ? DefaultCaloriesDetails : _ref3$CaloriesDetails,
132
+ _ref3$className = _ref3.className,
133
+ className = _ref3$className === void 0 ? "" : _ref3$className,
134
+ _ref3$DepartureDetail = _ref3.DepartureDetails,
135
+ DepartureDetails = _ref3$DepartureDetail === void 0 ? null : _ref3$DepartureDetail,
136
+ _ref3$defaultFareKey = _ref3.defaultFareKey,
137
+ defaultFareKey = _ref3$defaultFareKey === void 0 ? "regular" : _ref3$defaultFareKey,
138
+ _ref3$FareDetails = _ref3.FareDetails,
139
+ FareDetails = _ref3$FareDetails === void 0 ? null : _ref3$FareDetails,
140
+ _ref3$fareKeyNameMap = _ref3.fareKeyNameMap,
141
+ fareKeyNameMap = _ref3$fareKeyNameMap === void 0 ? {} : _ref3$fareKeyNameMap,
142
+ itinerary = _ref3.itinerary;
143
+ // process the transit fare
144
+ var fareResult = coreUtils.itinerary.calculateTncFares(itinerary);
145
+ var maxTNCFare = fareResult.maxTNCFare,
146
+ minTNCFare = fareResult.minTNCFare,
147
+ tncCurrencyCode = fareResult.tncCurrencyCode;
148
+ var transitFares = itinerary === null || itinerary === void 0 ? void 0 : (_itinerary$fare = itinerary.fare) === null || _itinerary$fare === void 0 ? void 0 : _itinerary$fare.fare;
149
+ var companies = "";
58
150
  itinerary.legs.forEach(function (leg) {
59
151
  if (leg.tncData) {
60
152
  companies = leg.tncData.company;
@@ -64,7 +156,12 @@ function TripDetails(_ref2) {
64
156
  var fareKeys = transitFares && Object.keys(transitFares).sort();
65
157
 
66
158
  if (transitFares && fareKeys.length > 0) {
67
- var dollarsToString = transitFares[defaultFare].dollarsToString; // Depending on if there are additional fares to display either render a <span> or a <details>
159
+ var defaultFare = defaultFareKey;
160
+
161
+ if (!transitFares[defaultFareKey]) {
162
+ defaultFare = "regular";
163
+ } // Depending on if there are additional fares to display either render a <span> or a <details>
164
+
68
165
 
69
166
  var TransitFareWrapper = transitFares && fareKeys.length > 1 ? S.TransitFare : S.TransitFareSingle;
70
167
  fare = /*#__PURE__*/React.createElement(S.Fare, null, /*#__PURE__*/React.createElement(TransitFareWrapper, null, /*#__PURE__*/React.createElement("summary", {
@@ -72,7 +169,11 @@ function TripDetails(_ref2) {
72
169
  display: fareKeys.length > 1 ? "list-item" : ""
73
170
  }
74
171
  }, /*#__PURE__*/React.createElement(TransitFare, {
75
- fareNameFallback: messages.transitFare,
172
+ fareNameFallback: /*#__PURE__*/React.createElement(FormattedMessage, {
173
+ defaultMessage: defaultMessages["otpUi.TripDetails.transitFare"],
174
+ description: "Text showing the price of tickets on public transportation.",
175
+ id: "otpUi.TripDetails.transitFare"
176
+ }),
76
177
  fareKey: defaultFare,
77
178
  fareKeyNameMap: fareKeyNameMap,
78
179
  transitFares: transitFares
@@ -88,25 +189,72 @@ function TripDetails(_ref2) {
88
189
  fareKeyNameMap: fareKeyNameMap,
89
190
  transitFares: transitFares
90
191
  });
91
- })), minTNCFare !== 0 && /*#__PURE__*/React.createElement(S.TNCFare, null, /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(S.TNCFareCompanies, null, companies.toLowerCase()), " ", messages.fare, ":", " ", /*#__PURE__*/React.createElement("b", null, dollarsToString(minTNCFare), " - ", dollarsToString(maxTNCFare))));
92
- } // Compute calories burned.
192
+ })), minTNCFare !== 0 && /*#__PURE__*/React.createElement(S.TNCFare, null, /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(FormattedMessage, {
193
+ defaultMessage: defaultMessages["otpUi.TripDetails.tncFare"],
194
+ description: "Text showing the price paid to transportation network companies.",
195
+ id: "otpUi.TripDetails.tncFare",
196
+ values: {
197
+ companies:
198
+ /*#__PURE__*/
199
+ // S.TNCFareCompanies capitalizes the TNC company ID (e.g. "COMPANY")
200
+ // after it is converted to lowercase, so it renders as "Company".
201
+ React.createElement(S.TNCFareCompanies, null, companies.toLowerCase()),
202
+ maxTNCFare: renderFare(tncCurrencyCode, maxTNCFare),
203
+ minTNCFare: renderFare(tncCurrencyCode, minTNCFare),
204
+ strong: boldText
205
+ }
206
+ })));
207
+ }
93
208
 
209
+ var departureDate = new Date(itinerary.startTime); // Compute calories burned.
94
210
 
95
- var _coreUtils$itinerary$2 = coreUtils.itinerary.calculatePhysicalActivity(itinerary),
96
- bikeDuration = _coreUtils$itinerary$2.bikeDuration,
97
- caloriesBurned = _coreUtils$itinerary$2.caloriesBurned,
98
- walkDuration = _coreUtils$itinerary$2.walkDuration;
211
+ var _coreUtils$itinerary$ = coreUtils.itinerary.calculatePhysicalActivity(itinerary),
212
+ bikeDuration = _coreUtils$itinerary$.bikeDuration,
213
+ caloriesBurned = _coreUtils$itinerary$.caloriesBurned,
214
+ walkDuration = _coreUtils$itinerary$.walkDuration; // Parse flex info and generate appropriate strings
99
215
 
216
+
217
+ var containsFlex = itinerary.legs.some(coreUtils.itinerary.isFlex);
218
+ var pickupBookingInfo = itinerary.legs.map(function (leg) {
219
+ return leg.pickupBookingInfo;
220
+ }).filter(function (info) {
221
+ return !!info;
222
+ });
223
+ var dropOffBookingInfo = itinerary.legs.map(function (leg) {
224
+ return leg.dropOffBookingInfo;
225
+ }).filter(function (info) {
226
+ return !!info;
227
+ });
100
228
  return /*#__PURE__*/React.createElement(S.TripDetails, {
101
229
  className: className
102
- }, /*#__PURE__*/React.createElement(S.TripDetailsHeader, null, messages.title), /*#__PURE__*/React.createElement(S.TripDetailsBody, null, /*#__PURE__*/React.createElement(TripDetail, {
103
- description: messages.departDescription,
230
+ }, /*#__PURE__*/React.createElement(S.TripDetailsHeader, null, /*#__PURE__*/React.createElement(FormattedMessage, {
231
+ defaultMessage: defaultMessages["otpUi.TripDetails.title"],
232
+ description: "Title (heading) text of the component.",
233
+ id: "otpUi.TripDetails.title"
234
+ })), /*#__PURE__*/React.createElement(S.TripDetailsBody, null, /*#__PURE__*/React.createElement(TripDetail // Any custom description for the Departure message needs to be handled by the slot.
235
+ , {
236
+ description: DepartureDetails && /*#__PURE__*/React.createElement(DepartureDetails, {
237
+ departureDate: departureDate
238
+ }),
104
239
  icon: /*#__PURE__*/React.createElement(CalendarAlt, {
105
240
  size: 17
106
241
  }),
107
- summary: /*#__PURE__*/React.createElement(S.Timing, null, /*#__PURE__*/React.createElement("span", null, messages.depart, " ", /*#__PURE__*/React.createElement("b", null, date.format(longDateFormat))), routingType === "ITINERARY" && /*#__PURE__*/React.createElement("span", null, " ", messages.at, " ", /*#__PURE__*/React.createElement("b", null, coreUtils.time.formatTime(itinerary.startTime, timeOptions))))
108
- }), fare && /*#__PURE__*/React.createElement(TripDetail, {
109
- description: messages.transitFareDescription,
242
+ summary: /*#__PURE__*/React.createElement(S.Timing, null, /*#__PURE__*/React.createElement(FormattedMessage, {
243
+ defaultMessage: defaultMessages["otpUi.TripDetails.departure"],
244
+ description: "Text showing the departure date/time for a trip.",
245
+ id: "otpUi.TripDetails.departure",
246
+ values: {
247
+ departureDate: departureDate,
248
+ strong: boldText
249
+ }
250
+ }))
251
+ }), fare && /*#__PURE__*/React.createElement(TripDetail // Any custom description for the transit fare needs to be handled by the slot.
252
+ , {
253
+ description: FareDetails && /*#__PURE__*/React.createElement(FareDetails, {
254
+ maxTNCFare: maxTNCFare,
255
+ minTNCFare: minTNCFare,
256
+ transitFares: transitFares
257
+ }),
110
258
  icon: /*#__PURE__*/React.createElement(MoneyBillAlt, {
111
259
  size: 17
112
260
  }),
@@ -115,77 +263,61 @@ function TripDetails(_ref2) {
115
263
  icon: /*#__PURE__*/React.createElement(Heartbeat, {
116
264
  size: 17
117
265
  }),
118
- summary: /*#__PURE__*/React.createElement(S.CaloriesSummary, null, messages.caloriesBurned, ": ", /*#__PURE__*/React.createElement("b", null, Math.round(caloriesBurned))),
119
- description: /*#__PURE__*/React.createElement(S.CaloriesDescription, null, "Calories burned is based on", " ", /*#__PURE__*/React.createElement("b", null, Math.round(walkDuration / 60), " minute(s)"), " spent walking and ", /*#__PURE__*/React.createElement("b", null, Math.round(bikeDuration / 60), " minute(s)"), " spent biking during this trip. Adapted from", " ", /*#__PURE__*/React.createElement("a", {
120
- href: "https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4",
121
- rel: "noopener noreferrer",
122
- target: "_blank"
123
- }, "Dietary Guidelines for Americans 2005, page 16, Table 4"), ".")
266
+ summary: /*#__PURE__*/React.createElement(S.CaloriesSummary, null, /*#__PURE__*/React.createElement(FormattedMessage, {
267
+ defaultMessage: defaultMessages["otpUi.TripDetails.calories"],
268
+ description: "Text showing the number of calories for the walking and biking legs of a trip.",
269
+ id: "otpUi.TripDetails.calories",
270
+ values: {
271
+ calories: caloriesBurned,
272
+ strong: boldText
273
+ }
274
+ })),
275
+ description: CaloriesDetails && /*#__PURE__*/React.createElement(CaloriesDetails, {
276
+ bikeSeconds: bikeDuration,
277
+ calories: caloriesBurned,
278
+ walkSeconds: walkDuration
279
+ })
280
+ }), containsFlex && /*#__PURE__*/React.createElement(TripDetail, {
281
+ summary: /*#__PURE__*/React.createElement(S.FlexSummary, null, /*#__PURE__*/React.createElement(FormattedMessage, {
282
+ defaultMessage: defaultMessages["otpUi.TripDetails.tripIncludesFlex"],
283
+ description: "Text stating that portions of the trip include a flex (on-demand) transit service.",
284
+ id: "otpUi.TripDetails.tripIncludesFlex"
285
+ })),
286
+ icon: /*#__PURE__*/React.createElement(Route, {
287
+ size: 17
288
+ })
289
+ }), pickupBookingInfo && pickupBookingInfo.map(function (info) {
290
+ return /*#__PURE__*/React.createElement(TripDetail, {
291
+ key: info.pickupMessage,
292
+ icon: /*#__PURE__*/React.createElement(PhoneVolume, {
293
+ size: 17
294
+ }),
295
+ summary: /*#__PURE__*/React.createElement(S.FlexPickupSummary, null, /*#__PURE__*/React.createElement(FormattedMessage, {
296
+ defaultMessage: defaultMessages["otpUi.TripDetails.flexPickupMessage"],
297
+ description: "Instructions for booking and boarding the flex (on-demand) transit service.",
298
+ id: "otpUi.TripDetails.flexPickupMessage",
299
+ values: getFlexMessageValues(info)
300
+ })),
301
+ description: info.pickupMessage
302
+ });
303
+ }), dropOffBookingInfo && dropOffBookingInfo.map(function (info) {
304
+ return /*#__PURE__*/React.createElement(TripDetail, {
305
+ description: info.dropOffMessage,
306
+ icon: coreUtils.itinerary.isAdvanceBookingRequired(info) ? /*#__PURE__*/React.createElement(PhoneVolume, {
307
+ size: 17
308
+ }) : /*#__PURE__*/React.createElement(HandPaper, {
309
+ size: 17
310
+ }),
311
+ key: info.dropOffMessage,
312
+ summary: /*#__PURE__*/React.createElement(S.FlexDropOffSummary, null, /*#__PURE__*/React.createElement(FormattedMessage, {
313
+ defaultMessage: defaultMessages["otpUi.TripDetails.flexDropOffMessage"],
314
+ description: "Instructions for getting off the flex (on-demand) transit service.",
315
+ id: "otpUi.TripDetails.flexDropOffMessage",
316
+ values: getFlexMessageValues(info)
317
+ }))
318
+ });
124
319
  })));
125
320
  }
126
-
127
- TripDetails.propTypes = {
128
- /** Used for additional styling with styled components for example. */
129
- className: PropTypes.string,
130
-
131
- /** Determines which transit fare should be displayed by default, should there be multiple transit fare types */
132
- defaultFareKey: PropTypes.string,
133
-
134
- /** Itinerary that the user has selected to view, contains multiple legs */
135
- itinerary: coreUtils.types.itineraryType.isRequired,
136
-
137
- /** Mapping between fare keys and human-readable names for them */
138
- fareKeyNameMap: PropTypes.shape(_defineProperty({}, PropTypes.string, PropTypes.string)),
139
-
140
- /** the desired format to use for a long date */
141
- longDateFormat: PropTypes.string,
142
-
143
- /**
144
- * messages to use for l10n/i8n
145
- *
146
- * Note: messages with default null values included here for visibility.
147
- * Overriding with a truthy string value will cause the expandable help
148
- * message to appear in trip details.
149
- */
150
- messages: PropTypes.shape({
151
- at: PropTypes.string,
152
- caloriesBurned: PropTypes.string,
153
- // FIXME: Add templated string description.
154
- caloriesBurnedDescription: PropTypes.string,
155
- depart: PropTypes.string,
156
- departDescription: PropTypes.string,
157
- title: PropTypes.string,
158
- fare: PropTypes.string,
159
- transitFare: PropTypes.string,
160
- transitFareDescription: PropTypes.string
161
- }),
162
-
163
- /** whether the routing type is an itinerary or a profile result */
164
- routingType: PropTypes.string,
165
-
166
- /** Contains the preferred format string for time display and a timezone offset */
167
- timeOptions: coreUtils.types.timeOptionsType
168
- };
169
- TripDetails.defaultProps = {
170
- className: null,
171
- defaultFareKey: "regular",
172
- fareKeyNameMap: {},
173
- longDateFormat: null,
174
- messages: {
175
- at: "at",
176
- caloriesBurned: "Calories Burned",
177
- // FIXME: Add templated string description.
178
- caloriesBurnedDescription: null,
179
- depart: "Depart",
180
- departDescription: null,
181
- title: "Trip Details",
182
- fare: "Fare",
183
- transitFare: "Transit Fare",
184
- transitFareDescription: null
185
- },
186
- routingType: "ITINERARY",
187
- timeOptions: null
188
- };
189
321
  export default TripDetails; // Rename styled components for export
190
322
 
191
323
  export { S as Styled };
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["coreUtils","moment","PropTypes","React","CalendarAlt","Heartbeat","MoneyBillAlt","S","TripDetail","TransitFare","fareKey","fareNameFallback","fareKeyNameMap","transitFares","currentFare","centsToString","transitFare","propTypes","string","isRequired","shape","func","number","defaultProps","undefined","TripDetails","className","defaultFareKey","itinerary","longDateFormat","messages","routingType","timeOptions","date","startTime","mergeMessages","calculateFares","maxTNCFare","minTNCFare","defaultFare","companies","legs","forEach","leg","tncData","company","fare","fareKeys","Object","keys","sort","length","dollarsToString","TransitFareWrapper","TransitFareSingle","display","map","toLowerCase","calculatePhysicalActivity","bikeDuration","caloriesBurned","walkDuration","title","departDescription","depart","format","at","time","formatTime","transitFareDescription","Math","round","types","itineraryType","caloriesBurnedDescription","timeOptionsType","Styled"],"mappings":";AAAA,OAAOA,SAAP,MAAsB,6BAAtB;AACA,OAAOC,MAAP,MAAmB,QAAnB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAASC,WAAT,QAA4B,oCAA5B;AACA,SAASC,SAAT,QAA0B,kCAA1B;AACA,SAASC,YAAT,QAA6B,qCAA7B;AAEA,OAAO,KAAKC,CAAZ,MAAmB,UAAnB;AACA,OAAOC,UAAP,MAAuB,eAAvB;;AAEA,IAAMC,WAAW,GAAG,SAAdA,WAAc,OAKd;AAAA,MAJJC,OAII,QAJJA,OAII;AAAA,MAHJC,gBAGI,QAHJA,gBAGI;AAAA,MAFJC,cAEI,QAFJA,cAEI;AAAA,MADJC,YACI,QADJA,YACI;AACJ,MAAMC,WAAW,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E,IAJnB;AAKRV,IAAAA,MAAM,EAAE,QALA;AAMRD,IAAAA,iBAAiB,EAAE,IANX;AAORD,IAAAA,KAAK,EAAE,cAPC;AAQRhB,IAAAA,IAAI,EAAE,MARE;AASR9B,IAAAA,WAAW,EAAE,cATL;AAURqD,IAAAA,sBAAsB,EAAE;AAVhB,GALe;AAiBzBtC,EAAAA,WAAW,EAAE,WAjBY;AAkBzBC,EAAAA,WAAW,EAAE;AAlBY,CAA3B;AAqBA,eAAeP,WAAf,C,CAEA;;AACA,SAASlB,CAAC,IAAIqE,MAAd","sourcesContent":["import coreUtils from \"@opentripplanner/core-utils\";\nimport moment from \"moment\";\nimport PropTypes from \"prop-types\";\nimport React from \"react\";\nimport { CalendarAlt } from \"@styled-icons/fa-solid/CalendarAlt\";\nimport { Heartbeat } from \"@styled-icons/fa-solid/Heartbeat\";\nimport { MoneyBillAlt } from \"@styled-icons/fa-solid/MoneyBillAlt\";\n\nimport * as S from \"./styled\";\nimport TripDetail from \"./trip-detail\";\n\nconst TransitFare = ({\n fareKey,\n fareNameFallback,\n fareKeyNameMap,\n transitFares\n}) => {\n const currentFare = transitFares[fareKey];\n\n return (\n <span>\n {fareKeyNameMap[fareKey] || fareNameFallback || fareKey}:{\" \"}\n <b>{currentFare.centsToString(currentFare.transitFare)}</b>\n </span>\n );\n};\nTransitFare.propTypes = {\n fareKey: PropTypes.string.isRequired,\n fareNameFallback: PropTypes.string,\n fareKeyNameMap: PropTypes.shape({\n [PropTypes.string]: PropTypes.string\n }).isRequired,\n transitFares: PropTypes.shape({\n centsToString: PropTypes.func,\n transitFare: PropTypes.number\n }).isRequired\n};\nTransitFare.defaultProps = {\n fareNameFallback: undefined\n};\n\nfunction TripDetails({\n className,\n defaultFareKey,\n itinerary,\n fareKeyNameMap,\n longDateFormat,\n messages,\n routingType,\n timeOptions\n}) {\n const date = moment(itinerary.startTime);\n messages = coreUtils.messages.mergeMessages(\n TripDetails.defaultProps.messages,\n messages\n );\n\n // process the transit fare\n const {\n maxTNCFare,\n minTNCFare,\n transitFares\n } = coreUtils.itinerary.calculateFares(itinerary, true);\n\n let defaultFare = defaultFareKey;\n if (!transitFares[defaultFareKey]) {\n defaultFare = \"regular\";\n }\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 const { dollarsToString } = transitFares[defaultFare];\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={messages.transitFare}\n fareKey={defaultFare}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n </summary>\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 </TransitFareWrapper>\n {minTNCFare !== 0 && (\n <S.TNCFare>\n <br />\n <S.TNCFareCompanies>\n {companies.toLowerCase()}\n </S.TNCFareCompanies>{\" \"}\n {messages.fare}:{\" \"}\n <b>\n {dollarsToString(minTNCFare)} - {dollarsToString(maxTNCFare)}\n </b>\n </S.TNCFare>\n )}\n </S.Fare>\n );\n }\n\n // Compute calories burned.\n const {\n bikeDuration,\n caloriesBurned,\n walkDuration\n } = coreUtils.itinerary.calculatePhysicalActivity(itinerary);\n\n return (\n <S.TripDetails className={className}>\n <S.TripDetailsHeader>{messages.title}</S.TripDetailsHeader>\n <S.TripDetailsBody>\n <TripDetail\n description={messages.departDescription}\n icon={<CalendarAlt size={17} />}\n summary={\n <S.Timing>\n <span>\n {messages.depart} <b>{date.format(longDateFormat)}</b>\n </span>\n {routingType === \"ITINERARY\" && (\n <span>\n {\" \"}\n {messages.at}{\" \"}\n <b>\n {coreUtils.time.formatTime(\n itinerary.startTime,\n timeOptions\n )}\n </b>\n </span>\n )}\n </S.Timing>\n }\n />\n {fare && (\n <TripDetail\n description={messages.transitFareDescription}\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 {messages.caloriesBurned}: <b>{Math.round(caloriesBurned)}</b>\n </S.CaloriesSummary>\n }\n description={\n <S.CaloriesDescription>\n Calories burned is based on{\" \"}\n <b>{Math.round(walkDuration / 60)} minute(s)</b> spent walking\n and <b>{Math.round(bikeDuration / 60)} minute(s)</b> spent\n biking during this trip. Adapted from{\" \"}\n <a\n href=\"https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n Dietary Guidelines for Americans 2005, page 16, Table 4\n </a>\n .\n </S.CaloriesDescription>\n }\n />\n )}\n </S.TripDetailsBody>\n </S.TripDetails>\n );\n}\n\nTripDetails.propTypes = {\n /** Used for additional styling with styled components for example. */\n className: PropTypes.string,\n /** Determines which transit fare should be displayed by default, should there be multiple transit fare types */\n defaultFareKey: PropTypes.string,\n /** Itinerary that the user has selected to view, contains multiple legs */\n itinerary: coreUtils.types.itineraryType.isRequired,\n /** Mapping between fare keys and human-readable names for them */\n fareKeyNameMap: PropTypes.shape({\n [PropTypes.string]: PropTypes.string\n }),\n /** the desired format to use for a long date */\n longDateFormat: PropTypes.string,\n /**\n * messages to use for l10n/i8n\n *\n * Note: messages with default null values included here for visibility.\n * Overriding with a truthy string value will cause the expandable help\n * message to appear in trip details.\n */\n messages: PropTypes.shape({\n at: PropTypes.string,\n caloriesBurned: PropTypes.string,\n // FIXME: Add templated string description.\n caloriesBurnedDescription: PropTypes.string,\n depart: PropTypes.string,\n departDescription: PropTypes.string,\n title: PropTypes.string,\n fare: PropTypes.string,\n transitFare: PropTypes.string,\n transitFareDescription: PropTypes.string\n }),\n /** whether the routing type is an itinerary or a profile result */\n routingType: PropTypes.string,\n /** Contains the preferred format string for time display and a timezone offset */\n timeOptions: coreUtils.types.timeOptionsType\n};\n\nTripDetails.defaultProps = {\n className: null,\n defaultFareKey: \"regular\",\n fareKeyNameMap: {},\n longDateFormat: null,\n messages: {\n at: \"at\",\n caloriesBurned: \"Calories Burned\",\n // FIXME: Add templated string description.\n caloriesBurnedDescription: null,\n depart: \"Depart\",\n departDescription: null,\n title: \"Trip Details\",\n fare: \"Fare\",\n transitFare: \"Transit Fare\",\n transitFareDescription: null\n },\n routingType: \"ITINERARY\",\n timeOptions: null\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","HandPaper","Heartbeat","MoneyBillAlt","PhoneVolume","Route","S","TripDetail","defaultEnglishMessages","defaultMessages","boldText","contents","renderFare","currencyCode","fare","dietaryLink","getFlexMessageValues","info","hasLeadTime","itinerary","isAdvanceBookingRequired","hasPhone","contactInfo","phoneNumber","leadDays","latestBookingTime","daysPrior","DefaultCaloriesDetails","bikeSeconds","calories","walkSeconds","bikeMinutes","Math","round","strong","walkMinutes","TransitFare","fareKey","fareNameFallback","fareKeyNameMap","transitFares","currentFare","name","value","currency","cents","TripDetails","CaloriesDetails","className","DepartureDetails","defaultFareKey","FareDetails","fareResult","calculateTncFares","maxTNCFare","minTNCFare","tncCurrencyCode","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","dropOffBookingInfo","pickupMessage","dropOffMessage","Styled"],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E,MAAA,IAAI,eAAE,oBAAC,WAAD;AAAa,QAAA,IAAI,EAAE;AAAnB,QAFR;AAGE,MAAA,OAAO,eACL,oBAAC,CAAD,CAAG,iBAAH,qBACE,oBAAC,gBAAD;AACE,QAAA,cAAc,EACZ9E,eAAe,CAAC,qCAAD,CAFnB;AAIE,QAAA,WAAW,EAAC,6EAJd;AAKE,QAAA,EAAE,EAAC,qCALL;AAME,QAAA,MAAM,EAAEO,oBAAoB,CAACC,IAAD;AAN9B,QADF,CAJJ;AAeE,MAAA,WAAW,EAAEA,IAAI,CAACsE;AAfpB,MADwB;AAAA,GAA1B,CAnFJ,EAsGGD,kBAAkB,IACjBA,kBAAkB,CAACd,GAAnB,CAAuB,UAAAvD,IAAI;AAAA,wBACzB,oBAAC,UAAD;AACE,MAAA,WAAW,EAAEA,IAAI,CAACuE,cADpB;AAEE,MAAA,IAAI,EACF5F,SAAS,CAACuB,SAAV,CAAoBC,wBAApB,CAA6CH,IAA7C,iBACE,oBAAC,WAAD;AAAa,QAAA,IAAI,EAAE;AAAnB,QADF,gBAGE,oBAAC,SAAD;AAAW,QAAA,IAAI,EAAE;AAAjB,QANN;AASE,MAAA,GAAG,EAAEA,IAAI,CAACuE,cATZ;AAUE,MAAA,OAAO,eACL,oBAAC,CAAD,CAAG,kBAAH,qBACE,oBAAC,gBAAD;AACE,QAAA,cAAc,EACZ/E,eAAe,CAAC,sCAAD,CAFnB;AAIE,QAAA,WAAW,EAAC,oEAJd;AAKE,QAAA,EAAE,EAAC,sCALL;AAME,QAAA,MAAM,EAAEO,oBAAoB,CAACC,IAAD;AAN9B,QADF;AAXJ,MADyB;AAAA,GAA3B,CAvGJ,CARF,CADF;AA4ID;AAED,eAAe6B,WAAf,C,CAEA;;AACA,SAASxC,CAAC,IAAImF,MAAd","sourcesContent":["import flatten from \"flat\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore FIXME: Create TypeScript types for core-utils packages.\nimport coreUtils from \"@opentripplanner/core-utils\";\nimport { FlexBookingInfo } from \"@opentripplanner/types\";\nimport React, { ReactElement } from \"react\";\nimport { FormattedMessage, FormattedNumber } from \"react-intl\";\nimport { CalendarAlt } from \"@styled-icons/fa-solid/CalendarAlt\";\nimport { HandPaper } from \"@styled-icons/fa-solid/HandPaper\";\nimport { Heartbeat } from \"@styled-icons/fa-solid/Heartbeat\";\nimport { MoneyBillAlt } from \"@styled-icons/fa-solid/MoneyBillAlt\";\nimport { PhoneVolume } from \"@styled-icons/fa-solid/PhoneVolume\";\nimport { Route } from \"@styled-icons/fa-solid/Route\";\n\nimport * as S from \"./styled\";\nimport TripDetail from \"./trip-detail\";\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 * Format text bold (used with FormattedMessage).\n */\n// TODO: Find a better place for this utility.\nfunction boldText(contents: ReactElement): ReactElement {\n return <strong>{contents}</strong>;\n}\n\n/**\n * Render formatted fare.\n * @param currencyCode The ISO currency code to use (USD, GBP, EUR).\n * @param fare The fare value, in currency units, to be shown.\n * @returns The formatted fare value according to the selected locale.\n */\nfunction renderFare(currencyCode: string, fare: number): ReactElement {\n return (\n <FormattedNumber\n currency={currencyCode}\n // For dollars in locales such as 'fr',\n // this will limit the display to just the dollar sign\n // (otherwise it will render e.g. '2,50 $US' instead of '2,50 $').\n currencyDisplay=\"narrowSymbol\"\n value={fare}\n // eslint-disable-next-line react/style-prop-object\n style=\"currency\"\n />\n );\n}\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/**\n * Helper function that assembles values for flex pickup/dropoff messages.\n */\nfunction getFlexMessageValues(info: FlexBookingInfo) {\n return {\n hasLeadTime: coreUtils.itinerary.isAdvanceBookingRequired(info),\n hasPhone: !!info?.contactInfo?.phoneNumber,\n leadDays: info.latestBookingTime.daysPrior,\n phoneNumber: info?.contactInfo?.phoneNumber\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 DepartureDetails = null,\n defaultFareKey = \"regular\",\n FareDetails = null,\n fareKeyNameMap = {},\n itinerary\n}: TripDetailsProps): ReactElement {\n // process the transit fare\n const fareResult = coreUtils.itinerary.calculateTncFares(itinerary);\n const { maxTNCFare, minTNCFare, tncCurrencyCode } = fareResult;\n const transitFares = itinerary?.fare?.fare;\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 {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 </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(tncCurrencyCode, maxTNCFare),\n minTNCFare: renderFare(tncCurrencyCode, 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 />\n </S.FlexSummary>\n }\n icon={<Route size={17} />}\n />\n )}\n {pickupBookingInfo &&\n pickupBookingInfo.map(info => (\n <TripDetail\n key={info.pickupMessage}\n icon={<PhoneVolume size={17} />}\n summary={\n <S.FlexPickupSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.flexPickupMessage\"]\n }\n description=\"Instructions for booking and boarding the flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.flexPickupMessage\"\n values={getFlexMessageValues(info)}\n />\n </S.FlexPickupSummary>\n }\n description={info.pickupMessage}\n />\n ))}\n {dropOffBookingInfo &&\n dropOffBookingInfo.map(info => (\n <TripDetail\n description={info.dropOffMessage}\n icon={\n coreUtils.itinerary.isAdvanceBookingRequired(info) ? (\n <PhoneVolume size={17} />\n ) : (\n <HandPaper size={17} />\n )\n }\n key={info.dropOffMessage}\n summary={\n <S.FlexDropOffSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.flexDropOffMessage\"]\n }\n description=\"Instructions for getting off the flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.flexDropOffMessage\"\n values={getFlexMessageValues(info)}\n />\n </S.FlexDropOffSummary>\n }\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
@@ -1,76 +1,88 @@
1
1
  import styled from "styled-components";
2
2
  var BaseButton = styled.button.withConfig({
3
3
  displayName: "styled__BaseButton",
4
- componentId: "sr23bt-0"
4
+ componentId: "sc-6q2ok2-0"
5
5
  })(["background:transparent;border:0;cursor:pointer;display:inline-block;font-size:14px;font-weight:400;line-height:1.42857143;margin:0;padding:0;text-decoration:none;touch-action:manipulation;user-select:none;vertical-align:middle;white-space:nowrap;"]);
6
6
  export var CaloriesDescription = styled.span.withConfig({
7
7
  displayName: "styled__CaloriesDescription",
8
- componentId: "sr23bt-1"
8
+ componentId: "sc-6q2ok2-1"
9
9
  })([""]);
10
10
  export var CaloriesSummary = styled.span.withConfig({
11
11
  displayName: "styled__CaloriesSummary",
12
- componentId: "sr23bt-2"
12
+ componentId: "sc-6q2ok2-2"
13
13
  })([""]);
14
14
  export var ExpandButton = styled(BaseButton).attrs({
15
15
  "aria-label": "What does this mean?"
16
16
  }).withConfig({
17
17
  displayName: "styled__ExpandButton",
18
- componentId: "sr23bt-3"
18
+ componentId: "sc-6q2ok2-3"
19
19
  })(["color:#00f;font-size:16px;margin-left:6px;margin-top:-2px;"]);
20
20
  export var Fare = styled.span.withConfig({
21
21
  displayName: "styled__Fare",
22
- componentId: "sr23bt-4"
22
+ componentId: "sc-6q2ok2-4"
23
23
  })([""]);
24
24
  export var HideButton = styled(BaseButton).withConfig({
25
25
  displayName: "styled__HideButton",
26
- componentId: "sr23bt-5"
26
+ componentId: "sc-6q2ok2-5"
27
27
  })(["float:right;"]);
28
28
  export var TNCFare = styled.span.withConfig({
29
29
  displayName: "styled__TNCFare",
30
- componentId: "sr23bt-6"
30
+ componentId: "sc-6q2ok2-6"
31
31
  })([""]);
32
32
  export var TNCFareCompanies = styled.span.withConfig({
33
33
  displayName: "styled__TNCFareCompanies",
34
- componentId: "sr23bt-7"
34
+ componentId: "sc-6q2ok2-7"
35
35
  })(["text-transform:capitalize;"]);
36
36
  export var Timing = styled.span.withConfig({
37
37
  displayName: "styled__Timing",
38
- componentId: "sr23bt-8"
38
+ componentId: "sc-6q2ok2-8"
39
39
  })([""]);
40
40
  export var TransitFare = styled.details.withConfig({
41
41
  displayName: "styled__TransitFare",
42
- componentId: "sr23bt-9"
42
+ componentId: "sc-6q2ok2-9"
43
43
  })(["display:inline-block;> span{display:block;padding-left:1.75ch;}"]);
44
44
  export var TransitFareSingle = styled.span.withConfig({
45
45
  displayName: "styled__TransitFareSingle",
46
- componentId: "sr23bt-10"
46
+ componentId: "sc-6q2ok2-10"
47
+ })([""]);
48
+ export var FlexSummary = styled.span.withConfig({
49
+ displayName: "styled__FlexSummary",
50
+ componentId: "sc-6q2ok2-11"
51
+ })([""]);
52
+ export var FlexPickupSummary = styled.span.withConfig({
53
+ displayName: "styled__FlexPickupSummary",
54
+ componentId: "sc-6q2ok2-12"
55
+ })([""]);
56
+ export var FlexDropOffSummary = styled.span.withConfig({
57
+ displayName: "styled__FlexDropOffSummary",
58
+ componentId: "sc-6q2ok2-13"
47
59
  })([""]);
48
60
  export var TripDetail = styled.div.withConfig({
49
61
  displayName: "styled__TripDetail",
50
- componentId: "sr23bt-11"
62
+ componentId: "sc-6q2ok2-14"
51
63
  })(["margin-top:6px;"]);
52
64
  export var TripDetailDescription = styled.div.withConfig({
53
65
  displayName: "styled__TripDetailDescription",
54
- componentId: "sr23bt-12"
66
+ componentId: "sc-6q2ok2-15"
55
67
  })(["background-color:#fff;border:1px solid #888;font-size:12px;margin-top:2px;padding:8px;"]);
56
68
  export var TripDetailIcon = styled.div.withConfig({
57
69
  displayName: "styled__TripDetailIcon",
58
- componentId: "sr23bt-13"
70
+ componentId: "sc-6q2ok2-16"
59
71
  })(["float:left;font-size:17px;"]);
60
72
  export var TripDetails = styled.div.withConfig({
61
73
  displayName: "styled__TripDetails",
62
- componentId: "sr23bt-14"
74
+ componentId: "sc-6q2ok2-17"
63
75
  })(["background-color:#eee;border-radius:6px;margin-bottom:15px;margin-top:16px;padding:10px 16px;"]);
64
76
  export var TripDetailsBody = styled.div.withConfig({
65
77
  displayName: "styled__TripDetailsBody",
66
- componentId: "sr23bt-15"
78
+ componentId: "sc-6q2ok2-18"
67
79
  })([""]);
68
80
  export var TripDetailsHeader = styled.div.withConfig({
69
81
  displayName: "styled__TripDetailsHeader",
70
- componentId: "sr23bt-16"
82
+ componentId: "sc-6q2ok2-19"
71
83
  })(["font-size:18px;font-weight:600;"]);
72
84
  export var TripDetailSummary = styled.div.withConfig({
73
85
  displayName: "styled__TripDetailSummary",
74
- componentId: "sr23bt-17"
86
+ componentId: "sc-6q2ok2-20"
75
87
  })(["margin-left:28px;padding-top:2px;display:flex;align-items:baseline;"]);
76
88
  //# sourceMappingURL=styled.js.map