@opentripplanner/trip-details 1.6.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -5,10 +5,17 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.TripDetails = TripDetails;
8
9
  exports.Styled = exports.default = void 0;
9
10
 
11
+ var _flat = _interopRequireDefault(require("flat"));
12
+
10
13
  var _coreUtils = _interopRequireDefault(require("@opentripplanner/core-utils"));
11
14
 
15
+ var _react = _interopRequireDefault(require("react"));
16
+
17
+ var _reactIntl = require("react-intl");
18
+
12
19
  var _CalendarAlt = require("@styled-icons/fa-solid/CalendarAlt");
13
20
 
14
21
  var _HandPaper = require("@styled-icons/fa-solid/HandPaper");
@@ -21,22 +28,109 @@ var _PhoneVolume = require("@styled-icons/fa-solid/PhoneVolume");
21
28
 
22
29
  var _Route = require("@styled-icons/fa-solid/Route");
23
30
 
24
- var _moment = _interopRequireDefault(require("moment"));
25
-
26
- var _propTypes = _interopRequireDefault(require("prop-types"));
27
-
28
- var _react = _interopRequireDefault(require("react"));
29
-
30
31
  var S = _interopRequireWildcard(require("./styled"));
31
32
 
32
33
  exports.Styled = S;
33
34
 
34
35
  var _tripDetail = _interopRequireDefault(require("./trip-detail"));
35
36
 
37
+ var _enUS = _interopRequireDefault(require("../i18n/en-US.yml"));
38
+
36
39
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
40
 
38
41
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
42
 
43
+ // @ts-expect-error FIXME: Create TypeScript types for core-utils packages.
44
+ // Load the default messages.
45
+ // HACK: We should flatten the messages loaded above because
46
+ // the YAML loaders behave differently between webpack and our version of jest:
47
+ // - the yaml loader for webpack returns a nested object,
48
+ // - the yaml loader for jest returns messages with flattened ids.
49
+ const defaultMessages = (0, _flat.default)(_enUS.default);
50
+ /**
51
+ * Format text bold (used with FormattedMessage).
52
+ */
53
+ // TODO: Find a better place for this utility.
54
+
55
+ function boldText(contents) {
56
+ return /*#__PURE__*/_react.default.createElement("strong", null, contents);
57
+ }
58
+ /**
59
+ * Render formatted fare.
60
+ * @param currencyCode The ISO currency code to use (USD, GBP, EUR).
61
+ * @param fare The fare value, in currency units, to be shown.
62
+ * @returns The formatted fare value according to the selected locale.
63
+ */
64
+
65
+
66
+ function renderFare(currencyCode, fare) {
67
+ return /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedNumber, {
68
+ currency: currencyCode // For dollars in locales such as 'fr',
69
+ // this will limit the display to just the dollar sign
70
+ // (otherwise it will render e.g. '2,50 $US' instead of '2,50 $').
71
+ ,
72
+ currencyDisplay: "narrowSymbol",
73
+ value: fare // eslint-disable-next-line react/style-prop-object
74
+ ,
75
+ style: "currency"
76
+ });
77
+ }
78
+ /**
79
+ * Helper function to specify the link to dietary table.
80
+ */
81
+
82
+
83
+ function dietaryLink(contents) {
84
+ return /*#__PURE__*/_react.default.createElement("a", {
85
+ href: "https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4",
86
+ rel: "noopener noreferrer",
87
+ target: "_blank"
88
+ }, contents);
89
+ }
90
+ /**
91
+ * Helper function that assembles values for flex pickup/dropoff messages.
92
+ */
93
+
94
+
95
+ function getFlexMessageValues(info) {
96
+ var _info$contactInfo, _info$contactInfo2;
97
+
98
+ return {
99
+ hasLeadTime: _coreUtils.default.itinerary.isAdvanceBookingRequired(info),
100
+ hasPhone: !!(info !== null && info !== void 0 && (_info$contactInfo = info.contactInfo) !== null && _info$contactInfo !== void 0 && _info$contactInfo.phoneNumber),
101
+ leadDays: info.latestBookingTime.daysPrior,
102
+ phoneNumber: info === null || info === void 0 ? void 0 : (_info$contactInfo2 = info.contactInfo) === null || _info$contactInfo2 === void 0 ? void 0 : _info$contactInfo2.phoneNumber
103
+ };
104
+ }
105
+ /**
106
+ * Default rendering if no component is provided for the CaloriesDetails
107
+ * slot in the TripDetails component.
108
+ */
109
+
110
+
111
+ function DefaultCaloriesDetails({
112
+ bikeSeconds,
113
+ calories,
114
+ walkSeconds
115
+ }) {
116
+ return /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
117
+ defaultMessage: defaultMessages["otpUi.TripDetails.caloriesDescription"],
118
+ description: "Text describing how the calories relate to the walking and biking duration of a trip.",
119
+ id: "otpUi.TripDetails.caloriesDescription",
120
+ values: {
121
+ bikeMinutes: Math.round(bikeSeconds / 60),
122
+ calories: Math.round(calories),
123
+ dietaryLink,
124
+ strong: boldText,
125
+ walkMinutes: Math.round(walkSeconds / 60)
126
+ }
127
+ });
128
+ }
129
+ /**
130
+ * Helper component that renders a transit fare entry.
131
+ */
132
+
133
+
40
134
  const TransitFare = ({
41
135
  fareKey,
42
136
  fareNameFallback,
@@ -44,50 +138,47 @@ const TransitFare = ({
44
138
  transitFares
45
139
  }) => {
46
140
  const currentFare = transitFares[fareKey];
47
- return /*#__PURE__*/_react.default.createElement("span", null, fareKeyNameMap[fareKey] || fareNameFallback || fareKey, ":", " ", /*#__PURE__*/_react.default.createElement("b", null, currentFare.centsToString(currentFare.transitFare)));
141
+ return /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
142
+ defaultMessage: defaultMessages["otpUi.TripDetails.transitFareEntry"],
143
+ description: "Text showing the price of tickets on public transportation.",
144
+ id: "otpUi.TripDetails.transitFareEntry",
145
+ values: {
146
+ name: fareKeyNameMap[fareKey] || fareNameFallback || fareKey,
147
+ strong: boldText,
148
+ value: renderFare(currentFare.currencyCode, currentFare.transitFare / 100)
149
+ }
150
+ }));
48
151
  };
152
+ /**
153
+ * Renders trip details such as departure instructions, fare amount, and calories spent.
154
+ */
49
155
 
50
- TransitFare.propTypes = {
51
- fareKey: _propTypes.default.string.isRequired,
52
- fareNameFallback: _propTypes.default.string,
53
- fareKeyNameMap: _propTypes.default.shape({
54
- [_propTypes.default.string]: _propTypes.default.string
55
- }).isRequired,
56
- transitFares: _propTypes.default.shape({
57
- centsToString: _propTypes.default.func,
58
- transitFare: _propTypes.default.number
59
- }).isRequired
60
- };
61
- TransitFare.defaultProps = {
62
- fareNameFallback: undefined
63
- };
64
156
 
65
157
  function TripDetails({
66
- className,
67
- defaultFareKey,
68
- itinerary,
69
- fareKeyNameMap,
70
- longDateFormat,
71
- messages,
72
- routingType,
73
- timeOptions
158
+ CaloriesDetails = DefaultCaloriesDetails,
159
+ className = "",
160
+ DepartureDetails = null,
161
+ defaultFareKey = "regular",
162
+ FareDetails = null,
163
+ fareKeyNameMap = {},
164
+ itinerary
74
165
  }) {
75
- const date = (0, _moment.default)(itinerary.startTime);
76
- messages = _coreUtils.default.messages.mergeMessages(TripDetails.defaultProps.messages, messages); // process the transit fare
166
+ // process the transit fare
167
+ const fareResult = _coreUtils.default.itinerary.calculateFares(itinerary, true);
77
168
 
78
169
  const {
79
170
  maxTNCFare,
80
171
  minTNCFare,
172
+ tncCurrencyCode,
81
173
  transitFares
82
- } = _coreUtils.default.itinerary.calculateFares(itinerary, true);
83
-
174
+ } = fareResult;
84
175
  let defaultFare = defaultFareKey;
85
176
 
86
177
  if (!transitFares[defaultFareKey]) {
87
178
  defaultFare = "regular";
88
179
  }
89
180
 
90
- let companies;
181
+ let companies = "";
91
182
  itinerary.legs.forEach(leg => {
92
183
  if (leg.tncData) {
93
184
  companies = leg.tncData.company;
@@ -97,17 +188,18 @@ function TripDetails({
97
188
  const fareKeys = transitFares && Object.keys(transitFares).sort();
98
189
 
99
190
  if (transitFares && fareKeys.length > 0) {
100
- const {
101
- dollarsToString
102
- } = transitFares[defaultFare]; // Depending on if there are additional fares to display either render a <span> or a <details>
103
-
191
+ // Depending on if there are additional fares to display either render a <span> or a <details>
104
192
  const TransitFareWrapper = transitFares && fareKeys.length > 1 ? S.TransitFare : S.TransitFareSingle;
105
193
  fare = /*#__PURE__*/_react.default.createElement(S.Fare, null, /*#__PURE__*/_react.default.createElement(TransitFareWrapper, null, /*#__PURE__*/_react.default.createElement("summary", {
106
194
  style: {
107
195
  display: fareKeys.length > 1 ? "list-item" : ""
108
196
  }
109
197
  }, /*#__PURE__*/_react.default.createElement(TransitFare, {
110
- fareNameFallback: messages.transitFare,
198
+ fareNameFallback: /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
199
+ defaultMessage: defaultMessages["otpUi.TripDetails.transitFare"],
200
+ description: "Text showing the price of tickets on public transportation.",
201
+ id: "otpUi.TripDetails.transitFare"
202
+ }),
111
203
  fareKey: defaultFare,
112
204
  fareKeyNameMap: fareKeyNameMap,
113
205
  transitFares: transitFares
@@ -123,9 +215,24 @@ function TripDetails({
123
215
  fareKeyNameMap: fareKeyNameMap,
124
216
  transitFares: transitFares
125
217
  });
126
- })), minTNCFare !== 0 && /*#__PURE__*/_react.default.createElement(S.TNCFare, null, /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(S.TNCFareCompanies, null, companies.toLowerCase()), " ", messages.fare, ":", " ", /*#__PURE__*/_react.default.createElement("b", null, dollarsToString(minTNCFare), " - ", dollarsToString(maxTNCFare))));
127
- } // Compute calories burned.
218
+ })), minTNCFare !== 0 && /*#__PURE__*/_react.default.createElement(S.TNCFare, null, /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
219
+ defaultMessage: defaultMessages["otpUi.TripDetails.tncFare"],
220
+ description: "Text showing the price paid to transportation network companies.",
221
+ id: "otpUi.TripDetails.tncFare",
222
+ values: {
223
+ companies:
224
+ /*#__PURE__*/
225
+ // S.TNCFareCompanies capitalizes the TNC company ID (e.g. "COMPANY")
226
+ // after it is converted to lowercase, so it renders as "Company".
227
+ _react.default.createElement(S.TNCFareCompanies, null, companies.toLowerCase()),
228
+ maxTNCFare: renderFare(tncCurrencyCode, maxTNCFare),
229
+ minTNCFare: renderFare(tncCurrencyCode, minTNCFare),
230
+ strong: boldText
231
+ }
232
+ })));
233
+ }
128
234
 
235
+ const departureDate = new Date(itinerary.startTime); // Compute calories burned.
129
236
 
130
237
  const {
131
238
  bikeDuration,
@@ -137,28 +244,36 @@ function TripDetails({
137
244
  const containsFlex = itinerary.legs.some(_coreUtils.default.itinerary.isFlex);
138
245
  const pickupBookingInfo = itinerary.legs.map(leg => leg.pickupBookingInfo).filter(info => !!info);
139
246
  const dropOffBookingInfo = itinerary.legs.map(leg => leg.dropOffBookingInfo).filter(info => !!info);
140
-
141
- const callString = info => {
142
- var _info$contactInfo;
143
-
144
- return `you must call ${(info === null || info === void 0 ? void 0 : (_info$contactInfo = info.contactInfo) === null || _info$contactInfo === void 0 ? void 0 : _info$contactInfo.phoneNumber) || "ahead"}`;
145
- }; // FIXME: internationalize with correct plurals
146
- // FIXME: support hours
147
- // TODO: make use of url?
148
-
149
-
150
- const advanceString = info => _coreUtils.default.itinerary.isAdvanceBookingRequired(info) ? `at least ${info.latestBookingTime.daysPrior} day(s) in advance` : "";
151
-
152
247
  return /*#__PURE__*/_react.default.createElement(S.TripDetails, {
153
248
  className: className
154
- }, /*#__PURE__*/_react.default.createElement(S.TripDetailsHeader, null, messages.title), /*#__PURE__*/_react.default.createElement(S.TripDetailsBody, null, /*#__PURE__*/_react.default.createElement(_tripDetail.default, {
155
- description: messages.departDescription,
249
+ }, /*#__PURE__*/_react.default.createElement(S.TripDetailsHeader, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
250
+ defaultMessage: defaultMessages["otpUi.TripDetails.title"],
251
+ description: "Title (heading) text of the component.",
252
+ id: "otpUi.TripDetails.title"
253
+ })), /*#__PURE__*/_react.default.createElement(S.TripDetailsBody, null, /*#__PURE__*/_react.default.createElement(_tripDetail.default // Any custom description for the Departure message needs to be handled by the slot.
254
+ , {
255
+ description: DepartureDetails && /*#__PURE__*/_react.default.createElement(DepartureDetails, {
256
+ departureDate: departureDate
257
+ }),
156
258
  icon: /*#__PURE__*/_react.default.createElement(_CalendarAlt.CalendarAlt, {
157
259
  size: 17
158
260
  }),
159
- summary: /*#__PURE__*/_react.default.createElement(S.Timing, null, /*#__PURE__*/_react.default.createElement("span", null, messages.depart, " ", /*#__PURE__*/_react.default.createElement("b", null, date.format(longDateFormat))), routingType === "ITINERARY" && /*#__PURE__*/_react.default.createElement("span", null, " ", messages.at, " ", /*#__PURE__*/_react.default.createElement("b", null, _coreUtils.default.time.formatTime(itinerary.startTime, timeOptions))))
160
- }), fare && /*#__PURE__*/_react.default.createElement(_tripDetail.default, {
161
- description: messages.transitFareDescription,
261
+ summary: /*#__PURE__*/_react.default.createElement(S.Timing, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
262
+ defaultMessage: defaultMessages["otpUi.TripDetails.departure"],
263
+ description: "Text showing the departure date/time for a trip.",
264
+ id: "otpUi.TripDetails.departure",
265
+ values: {
266
+ departureDate,
267
+ strong: boldText
268
+ }
269
+ }))
270
+ }), fare && /*#__PURE__*/_react.default.createElement(_tripDetail.default // Any custom description for the transit fare needs to be handled by the slot.
271
+ , {
272
+ description: FareDetails && /*#__PURE__*/_react.default.createElement(FareDetails, {
273
+ maxTNCFare: maxTNCFare,
274
+ minTNCFare: minTNCFare,
275
+ transitFares: transitFares
276
+ }),
162
277
  icon: /*#__PURE__*/_react.default.createElement(_MoneyBillAlt.MoneyBillAlt, {
163
278
  size: 17
164
279
  }),
@@ -167,14 +282,26 @@ function TripDetails({
167
282
  icon: /*#__PURE__*/_react.default.createElement(_Heartbeat.Heartbeat, {
168
283
  size: 17
169
284
  }),
170
- summary: /*#__PURE__*/_react.default.createElement(S.CaloriesSummary, null, messages.caloriesBurned, ": ", /*#__PURE__*/_react.default.createElement("b", null, Math.round(caloriesBurned))),
171
- description: /*#__PURE__*/_react.default.createElement(S.CaloriesDescription, null, "Calories burned is based on", " ", /*#__PURE__*/_react.default.createElement("b", null, Math.round(walkDuration / 60), " minute(s)"), " spent walking and ", /*#__PURE__*/_react.default.createElement("b", null, Math.round(bikeDuration / 60), " minute(s)"), " spent biking during this trip. Adapted from", " ", /*#__PURE__*/_react.default.createElement("a", {
172
- href: "https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4",
173
- rel: "noopener noreferrer",
174
- target: "_blank"
175
- }, "Dietary Guidelines for Americans 2005, page 16, Table 4"), ".")
285
+ summary: /*#__PURE__*/_react.default.createElement(S.CaloriesSummary, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
286
+ defaultMessage: defaultMessages["otpUi.TripDetails.calories"],
287
+ description: "Text showing the number of calories for the walking and biking legs of a trip.",
288
+ id: "otpUi.TripDetails.calories",
289
+ values: {
290
+ calories: caloriesBurned,
291
+ strong: boldText
292
+ }
293
+ })),
294
+ description: CaloriesDetails && /*#__PURE__*/_react.default.createElement(CaloriesDetails, {
295
+ bikeSeconds: bikeDuration,
296
+ calories: caloriesBurned,
297
+ walkSeconds: walkDuration
298
+ })
176
299
  }), containsFlex && /*#__PURE__*/_react.default.createElement(_tripDetail.default, {
177
- summary: "This trip includes flexible routes.",
300
+ summary: /*#__PURE__*/_react.default.createElement(S.FlexSummary, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
301
+ defaultMessage: defaultMessages["otpUi.TripDetails.tripIncludesFlex"],
302
+ description: "Text stating that portions of the trip include a flex (on-demand) transit service.",
303
+ id: "otpUi.TripDetails.tripIncludesFlex"
304
+ })),
178
305
  icon: /*#__PURE__*/_react.default.createElement(_Route.Route, {
179
306
  size: 17
180
307
  })
@@ -183,7 +310,12 @@ function TripDetails({
183
310
  icon: /*#__PURE__*/_react.default.createElement(_PhoneVolume.PhoneVolume, {
184
311
  size: 17
185
312
  }),
186
- summary: `To take this route, ${callString(info)} ${advanceString(info)}.`,
313
+ summary: /*#__PURE__*/_react.default.createElement(S.FlexPickupSummary, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
314
+ defaultMessage: defaultMessages["otpUi.TripDetails.flexPickupMessage"],
315
+ description: "Instructions for booking and boarding the flex (on-demand) transit service.",
316
+ id: "otpUi.TripDetails.flexPickupMessage",
317
+ values: getFlexMessageValues(info)
318
+ })),
187
319
  description: info.pickupMessage
188
320
  })), dropOffBookingInfo && dropOffBookingInfo.map(info => /*#__PURE__*/_react.default.createElement(_tripDetail.default, {
189
321
  description: info.dropOffMessage,
@@ -193,74 +325,15 @@ function TripDetails({
193
325
  size: 17
194
326
  }),
195
327
  key: info.dropOffMessage,
196
- summary: _coreUtils.default.itinerary.isAdvanceBookingRequired(info) ? `To get off at your destination, ${callString(info)} ${advanceString(info)}.` : `You must tell the operator where you want to get off ${advanceString(info)}.`
328
+ summary: /*#__PURE__*/_react.default.createElement(S.FlexDropOffSummary, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
329
+ defaultMessage: defaultMessages["otpUi.TripDetails.flexDropOffMessage"],
330
+ description: "Instructions for getting off the flex (on-demand) transit service.",
331
+ id: "otpUi.TripDetails.flexDropOffMessage",
332
+ values: getFlexMessageValues(info)
333
+ }))
197
334
  }))));
198
335
  }
199
336
 
200
- TripDetails.propTypes = {
201
- /** Used for additional styling with styled components for example. */
202
- className: _propTypes.default.string,
203
-
204
- /** Determines which transit fare should be displayed by default, should there be multiple transit fare types */
205
- defaultFareKey: _propTypes.default.string,
206
-
207
- /** Itinerary that the user has selected to view, contains multiple legs */
208
- itinerary: _coreUtils.default.types.itineraryType.isRequired,
209
-
210
- /** Mapping between fare keys and human-readable names for them */
211
- fareKeyNameMap: _propTypes.default.shape({
212
- [_propTypes.default.string]: _propTypes.default.string
213
- }),
214
-
215
- /** the desired format to use for a long date */
216
- longDateFormat: _propTypes.default.string,
217
-
218
- /**
219
- * messages to use for l10n/i8n
220
- *
221
- * Note: messages with default null values included here for visibility.
222
- * Overriding with a truthy string value will cause the expandable help
223
- * message to appear in trip details.
224
- */
225
- messages: _propTypes.default.shape({
226
- at: _propTypes.default.string,
227
- caloriesBurned: _propTypes.default.string,
228
- // FIXME: Add templated string description.
229
- caloriesBurnedDescription: _propTypes.default.string,
230
- depart: _propTypes.default.string,
231
- departDescription: _propTypes.default.string,
232
- title: _propTypes.default.string,
233
- fare: _propTypes.default.string,
234
- transitFare: _propTypes.default.string,
235
- transitFareDescription: _propTypes.default.string
236
- }),
237
-
238
- /** whether the routing type is an itinerary or a profile result */
239
- routingType: _propTypes.default.string,
240
-
241
- /** Contains the preferred format string for time display and a timezone offset */
242
- timeOptions: _coreUtils.default.types.timeOptionsType
243
- };
244
- TripDetails.defaultProps = {
245
- className: null,
246
- defaultFareKey: "regular",
247
- fareKeyNameMap: {},
248
- longDateFormat: null,
249
- messages: {
250
- at: "at",
251
- caloriesBurned: "Calories Burned",
252
- // FIXME: Add templated string description.
253
- caloriesBurnedDescription: null,
254
- depart: "Depart",
255
- departDescription: null,
256
- title: "Trip Details",
257
- fare: "Fare",
258
- transitFare: "Transit Fare",
259
- transitFareDescription: null
260
- },
261
- routingType: "ITINERARY",
262
- timeOptions: null
263
- };
264
337
  var _default = TripDetails; // Rename styled components for export
265
338
 
266
339
  exports.default = _default;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["TransitFare","fareKey","fareNameFallback","fareKeyNameMap","transitFares","currentFare","centsToString","transitFare","propTypes","PropTypes","string","isRequired","shape","func","number","defaultProps","undefined","TripDetails","className","defaultFareKey","itinerary","longDateFormat","messages","routingType","timeOptions","date","startTime","coreUtils","mergeMessages","maxTNCFare","minTNCFare","calculateFares","defaultFare","companies","legs","forEach","leg","tncData","company","fare","fareKeys","Object","keys","sort","length","dollarsToString","TransitFareWrapper","S","TransitFareSingle","display","map","toLowerCase","bikeDuration","caloriesBurned","walkDuration","calculatePhysicalActivity","containsFlex","some","isFlex","pickupBookingInfo","filter","info","dropOffBookingInfo","callString","contactInfo","phoneNumber","advanceString","isAdvanceBookingRequired","latestBookingTime","daysPrior","title","departDescription","depart","format","at","time","formatTime","transitFareDescription","Math","round","pickupMessage","dropOffMessage","types","itineraryType","caloriesBurnedDescription","timeOptionsType"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;AACA;;;;;;AAEA,MAAMA,WAAW,GAAG,CAAC;AACnBC,EAAAA,OADmB;AAEnBC,EAAAA,gBAFmB;AAGnBC,EAAAA,cAHmB;AAInBC,EAAAA;AAJmB,CAAD,KAKd;AACJ,QAAMC,WAAW,GAAGD,YAAY,CAACH,OAAD,CAAhC;AAEA,sBACE,2CACGE,cAAc,CAACF,OAAD,CAAd,IAA2BC,gBAA3B,IAA+CD,OADlD,OAC4D,GAD5D,eAEE,wCAAII,WAAW,CAACC,aAAZ,CAA0BD,WAAW,CAACE,WAAtC,CAAJ,CAFF,CADF;AAMD,CAdD;;AAeAP,WAAW,CAACQ,SAAZ,GAAwB;AACtBP,EAAAA,OAAO,EAAEQ,mBAAUC,MAAV,CAAiBC,UADJ;AAEtBT,EAAAA,gBAAgB,EAAEO,mBAAUC,MAFN;AAGtBP,EAAAA,cAAc,EAAEM,mBAAUG,KAAV,C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,IAAAA,yBAAyB,EAAE,IAJnB;AAKRZ,IAAAA,MAAM,EAAE,QALA;AAMRD,IAAAA,iBAAiB,EAAE,IANX;AAORD,IAAAA,KAAK,EAAE,cAPC;AAQR/B,IAAAA,IAAI,EAAE,MARE;AASRhC,IAAAA,WAAW,EAAE,cATL;AAURsE,IAAAA,sBAAsB,EAAE;AAVhB,GALe;AAiBzBtD,EAAAA,WAAW,EAAE,WAjBY;AAkBzBC,EAAAA,WAAW,EAAE;AAlBY,CAA3B;eAqBeP,W,EAEf","sourcesContent":["import coreUtils from \"@opentripplanner/core-utils\";\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\";\nimport moment from \"moment\";\nimport PropTypes from \"prop-types\";\nimport React from \"react\";\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 // 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 const callString = info =>\n `you must call ${info?.contactInfo?.phoneNumber || \"ahead\"}`;\n // FIXME: internationalize with correct plurals\n // FIXME: support hours\n // TODO: make use of url?\n const advanceString = info =>\n coreUtils.itinerary.isAdvanceBookingRequired(info)\n ? `at least ${info.latestBookingTime.daysPrior} day(s) in advance`\n : \"\";\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 {containsFlex && (\n <TripDetail\n summary=\"This trip includes flexible routes.\"\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={`To take this route, ${callString(info)} ${advanceString(\n info\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 coreUtils.itinerary.isAdvanceBookingRequired(info)\n ? `To get off at your destination, ${callString(\n info\n )} ${advanceString(info)}.`\n : `You must tell the operator where you want to get off ${advanceString(\n info\n )}.`\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":["defaultMessages","defaultEnglishMessages","boldText","contents","renderFare","currencyCode","fare","dietaryLink","getFlexMessageValues","info","hasLeadTime","coreUtils","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","transitFare","TripDetails","CaloriesDetails","className","DepartureDetails","defaultFareKey","FareDetails","fareResult","calculateFares","maxTNCFare","minTNCFare","tncCurrencyCode","defaultFare","companies","legs","forEach","leg","tncData","company","fareKeys","Object","keys","sort","length","TransitFareWrapper","S","TransitFareSingle","display","map","toLowerCase","departureDate","Date","startTime","bikeDuration","caloriesBurned","walkDuration","calculatePhysicalActivity","containsFlex","some","isFlex","pickupBookingInfo","filter","dropOffBookingInfo","pickupMessage","dropOffMessage"],"mappings":";;;;;;;;;;AAAA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;AACA;;AASA;;;;;;AAtBA;AAqBA;AAGA;AACA;AACA;AACA;AACA,MAAMA,eAAuC,GAAG,mBAAQC,aAAR,CAAhD;AAEA;AACA;AACA;AACA;;AACA,SAASC,QAAT,CAAkBC,QAAlB,EAAwD;AACtD,sBAAO,6CAASA,QAAT,CAAP;AACD;AAED;AAC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AA,IAAI,eAAE,6BAAC,wBAAD;AAAa,MAAA,IAAI,EAAE;AAAnB,MAFR;AAGE,IAAA,OAAO,eACL,6BAAC,CAAD,CAAG,iBAAH,qBACE,6BAAC,2BAAD;AACE,MAAA,cAAc,EACZhF,eAAe,CAAC,qCAAD,CAFnB;AAIE,MAAA,WAAW,EAAC,6EAJd;AAKE,MAAA,EAAE,EAAC,qCALL;AAME,MAAA,MAAM,EAAEQ,oBAAoB,CAACC,IAAD;AAN9B,MADF,CAJJ;AAeE,IAAA,WAAW,EAAEA,IAAI,CAACuE;AAfpB,IADF,CAnFJ,EAsGGD,kBAAkB,IACjBA,kBAAkB,CAACd,GAAnB,CAAuBxD,IAAI,iBACzB,6BAAC,mBAAD;AACE,IAAA,WAAW,EAAEA,IAAI,CAACwE,cADpB;AAEE,IAAA,IAAI,EACFtE,mBAAUC,SAAV,CAAoBC,wBAApB,CAA6CJ,IAA7C,iBACE,6BAAC,wBAAD;AAAa,MAAA,IAAI,EAAE;AAAnB,MADF,gBAGE,6BAAC,oBAAD;AAAW,MAAA,IAAI,EAAE;AAAjB,MANN;AASE,IAAA,GAAG,EAAEA,IAAI,CAACwE,cATZ;AAUE,IAAA,OAAO,eACL,6BAAC,CAAD,CAAG,kBAAH,qBACE,6BAAC,2BAAD;AACE,MAAA,cAAc,EACZjF,eAAe,CAAC,sCAAD,CAFnB;AAIE,MAAA,WAAW,EAAC,oEAJd;AAKE,MAAA,EAAE,EAAC,sCALL;AAME,MAAA,MAAM,EAAEQ,oBAAoB,CAACC,IAAD;AAN9B,MADF;AAXJ,IADF,CAvGJ,CARF,CADF;AA4ID;;eAEc6B,W,EAEf","sourcesContent":["import flatten from \"flat\";\n// @ts-expect-error 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.currencyCode,\n currentFare.transitFare / 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.calculateFares(itinerary, true);\n const { maxTNCFare, minTNCFare, tncCurrencyCode, transitFares } = fareResult;\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 // 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"}
@@ -0,0 +1,23 @@
1
+ export declare const CaloriesDescription: import("styled-components").StyledComponent<"span", any, {}, never>;
2
+ export declare const CaloriesSummary: import("styled-components").StyledComponent<"span", any, {}, never>;
3
+ export declare const ExpandButton: import("styled-components").StyledComponent<"button", any, {
4
+ "aria-label": "What does this mean?";
5
+ }, "aria-label">;
6
+ export declare const Fare: import("styled-components").StyledComponent<"span", any, {}, never>;
7
+ export declare const HideButton: import("styled-components").StyledComponent<"button", any, {}, never>;
8
+ export declare const TNCFare: import("styled-components").StyledComponent<"span", any, {}, never>;
9
+ export declare const TNCFareCompanies: import("styled-components").StyledComponent<"span", any, {}, never>;
10
+ export declare const Timing: import("styled-components").StyledComponent<"span", any, {}, never>;
11
+ export declare const TransitFare: import("styled-components").StyledComponent<"details", any, {}, never>;
12
+ export declare const TransitFareSingle: import("styled-components").StyledComponent<"span", any, {}, never>;
13
+ export declare const FlexSummary: import("styled-components").StyledComponent<"span", any, {}, never>;
14
+ export declare const FlexPickupSummary: import("styled-components").StyledComponent<"span", any, {}, never>;
15
+ export declare const FlexDropOffSummary: import("styled-components").StyledComponent<"span", any, {}, never>;
16
+ export declare const TripDetail: import("styled-components").StyledComponent<"div", any, {}, never>;
17
+ export declare const TripDetailDescription: import("styled-components").StyledComponent<"div", any, {}, never>;
18
+ export declare const TripDetailIcon: import("styled-components").StyledComponent<"div", any, {}, never>;
19
+ export declare const TripDetails: import("styled-components").StyledComponent<"div", any, {}, never>;
20
+ export declare const TripDetailsBody: import("styled-components").StyledComponent<"div", any, {}, never>;
21
+ export declare const TripDetailsHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
22
+ export declare const TripDetailSummary: import("styled-components").StyledComponent<"div", any, {}, never>;
23
+ //# sourceMappingURL=styled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,mBAAmB,qEAAgB,CAAC;AAEjD,eAAO,MAAM,eAAe,qEAAgB,CAAC;AAE7C,eAAO,MAAM,YAAY;;gBAOxB,CAAC;AAEF,eAAO,MAAM,IAAI,qEAAgB,CAAC;AAElC,eAAO,MAAM,UAAU,uEAEtB,CAAC;AAEF,eAAO,MAAM,OAAO,qEAAgB,CAAC;AAErC,eAAO,MAAM,gBAAgB,qEAE5B,CAAC;AAEF,eAAO,MAAM,MAAM,qEAAgB,CAAC;AAEpC,eAAO,MAAM,WAAW,wEASvB,CAAC;AACF,eAAO,MAAM,iBAAiB,qEAAgB,CAAC;AAE/C,eAAO,MAAM,WAAW,qEAAgB,CAAC;AAEzC,eAAO,MAAM,iBAAiB,qEAAgB,CAAC;AAE/C,eAAO,MAAM,kBAAkB,qEAAgB,CAAC;AAEhD,eAAO,MAAM,UAAU,oEAEtB,CAAC;AAEF,eAAO,MAAM,qBAAqB,oEAMjC,CAAC;AAEF,eAAO,MAAM,cAAc,oEAG1B,CAAC;AAEF,eAAO,MAAM,WAAW,oEAMvB,CAAC;AAEF,eAAO,MAAM,eAAe,oEAAe,CAAC;AAE5C,eAAO,MAAM,iBAAiB,oEAG7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,oEAK7B,CAAC"}