@opentripplanner/trip-details 1.6.0 → 2.0.2-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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,110 @@ 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
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
44
+ // @ts-ignore FIXME: Create TypeScript types for core-utils packages.
45
+ // Load the default messages.
46
+ // HACK: We should flatten the messages loaded above because
47
+ // the YAML loaders behave differently between webpack and our version of jest:
48
+ // - the yaml loader for webpack returns a nested object,
49
+ // - the yaml loader for jest returns messages with flattened ids.
50
+ const defaultMessages = (0, _flat.default)(_enUS.default);
51
+ /**
52
+ * Format text bold (used with FormattedMessage).
53
+ */
54
+ // TODO: Find a better place for this utility.
55
+
56
+ function boldText(contents) {
57
+ return /*#__PURE__*/_react.default.createElement("strong", null, contents);
58
+ }
59
+ /**
60
+ * Render formatted fare.
61
+ * @param currencyCode The ISO currency code to use (USD, GBP, EUR).
62
+ * @param fare The fare value, in currency units, to be shown.
63
+ * @returns The formatted fare value according to the selected locale.
64
+ */
65
+
66
+
67
+ function renderFare(currencyCode, fare) {
68
+ return /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedNumber, {
69
+ currency: currencyCode // For dollars in locales such as 'fr',
70
+ // this will limit the display to just the dollar sign
71
+ // (otherwise it will render e.g. '2,50 $US' instead of '2,50 $').
72
+ ,
73
+ currencyDisplay: "narrowSymbol",
74
+ value: fare // eslint-disable-next-line react/style-prop-object
75
+ ,
76
+ style: "currency"
77
+ });
78
+ }
79
+ /**
80
+ * Helper function to specify the link to dietary table.
81
+ */
82
+
83
+
84
+ function dietaryLink(contents) {
85
+ return /*#__PURE__*/_react.default.createElement("a", {
86
+ href: "https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4",
87
+ rel: "noopener noreferrer",
88
+ target: "_blank"
89
+ }, contents);
90
+ }
91
+ /**
92
+ * Helper function that assembles values for flex pickup/dropoff messages.
93
+ */
94
+
95
+
96
+ function getFlexMessageValues(info) {
97
+ var _info$contactInfo, _info$contactInfo2;
98
+
99
+ return {
100
+ hasLeadTime: _coreUtils.default.itinerary.isAdvanceBookingRequired(info),
101
+ hasPhone: !!(info !== null && info !== void 0 && (_info$contactInfo = info.contactInfo) !== null && _info$contactInfo !== void 0 && _info$contactInfo.phoneNumber),
102
+ leadDays: info.latestBookingTime.daysPrior,
103
+ phoneNumber: info === null || info === void 0 ? void 0 : (_info$contactInfo2 = info.contactInfo) === null || _info$contactInfo2 === void 0 ? void 0 : _info$contactInfo2.phoneNumber
104
+ };
105
+ }
106
+ /**
107
+ * Default rendering if no component is provided for the CaloriesDetails
108
+ * slot in the TripDetails component.
109
+ */
110
+
111
+
112
+ function DefaultCaloriesDetails({
113
+ bikeSeconds,
114
+ calories,
115
+ walkSeconds
116
+ }) {
117
+ return /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
118
+ defaultMessage: defaultMessages["otpUi.TripDetails.caloriesDescription"],
119
+ description: "Text describing how the calories relate to the walking and biking duration of a trip.",
120
+ id: "otpUi.TripDetails.caloriesDescription",
121
+ values: {
122
+ bikeMinutes: Math.round(bikeSeconds / 60),
123
+ calories: Math.round(calories),
124
+ dietaryLink,
125
+ strong: boldText,
126
+ walkMinutes: Math.round(walkSeconds / 60)
127
+ }
128
+ });
129
+ }
130
+ /**
131
+ * Helper component that renders a transit fare entry.
132
+ */
133
+
134
+
40
135
  const TransitFare = ({
41
136
  fareKey,
42
137
  fareNameFallback,
@@ -44,50 +139,43 @@ const TransitFare = ({
44
139
  transitFares
45
140
  }) => {
46
141
  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)));
142
+ return /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
143
+ defaultMessage: defaultMessages["otpUi.TripDetails.transitFareEntry"],
144
+ description: "Text showing the price of tickets on public transportation.",
145
+ id: "otpUi.TripDetails.transitFareEntry",
146
+ values: {
147
+ name: fareKeyNameMap[fareKey] || fareNameFallback || fareKey,
148
+ strong: boldText,
149
+ value: renderFare(currentFare.currency.currencyCode, currentFare.cents / 100)
150
+ }
151
+ }));
48
152
  };
153
+ /**
154
+ * Renders trip details such as departure instructions, fare amount, and calories spent.
155
+ */
49
156
 
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
157
 
65
158
  function TripDetails({
66
- className,
67
- defaultFareKey,
68
- itinerary,
69
- fareKeyNameMap,
70
- longDateFormat,
71
- messages,
72
- routingType,
73
- timeOptions
159
+ CaloriesDetails = DefaultCaloriesDetails,
160
+ className = "",
161
+ DepartureDetails = null,
162
+ defaultFareKey = "regular",
163
+ FareDetails = null,
164
+ fareKeyNameMap = {},
165
+ itinerary
74
166
  }) {
75
- const date = (0, _moment.default)(itinerary.startTime);
76
- messages = _coreUtils.default.messages.mergeMessages(TripDetails.defaultProps.messages, messages); // process the transit fare
167
+ var _itinerary$fare;
168
+
169
+ // process the transit fare
170
+ const fareResult = _coreUtils.default.itinerary.calculateTncFares(itinerary);
77
171
 
78
172
  const {
79
173
  maxTNCFare,
80
174
  minTNCFare,
81
- transitFares
82
- } = _coreUtils.default.itinerary.calculateFares(itinerary, true);
83
-
84
- let defaultFare = defaultFareKey;
85
-
86
- if (!transitFares[defaultFareKey]) {
87
- defaultFare = "regular";
88
- }
89
-
90
- let companies;
175
+ tncCurrencyCode
176
+ } = fareResult;
177
+ const transitFares = itinerary === null || itinerary === void 0 ? void 0 : (_itinerary$fare = itinerary.fare) === null || _itinerary$fare === void 0 ? void 0 : _itinerary$fare.fare;
178
+ let companies = "";
91
179
  itinerary.legs.forEach(leg => {
92
180
  if (leg.tncData) {
93
181
  companies = leg.tncData.company;
@@ -97,17 +185,25 @@ function TripDetails({
97
185
  const fareKeys = transitFares && Object.keys(transitFares).sort();
98
186
 
99
187
  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>
188
+ let defaultFare = defaultFareKey;
189
+
190
+ if (!transitFares[defaultFareKey]) {
191
+ defaultFare = "regular";
192
+ } // Depending on if there are additional fares to display either render a <span> or a <details>
193
+
103
194
 
104
195
  const TransitFareWrapper = transitFares && fareKeys.length > 1 ? S.TransitFare : S.TransitFareSingle;
105
196
  fare = /*#__PURE__*/_react.default.createElement(S.Fare, null, /*#__PURE__*/_react.default.createElement(TransitFareWrapper, null, /*#__PURE__*/_react.default.createElement("summary", {
197
+ role: "button",
106
198
  style: {
107
199
  display: fareKeys.length > 1 ? "list-item" : ""
108
200
  }
109
201
  }, /*#__PURE__*/_react.default.createElement(TransitFare, {
110
- fareNameFallback: messages.transitFare,
202
+ fareNameFallback: /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
203
+ defaultMessage: defaultMessages["otpUi.TripDetails.transitFare"],
204
+ description: "Text showing the price of tickets on public transportation.",
205
+ id: "otpUi.TripDetails.transitFare"
206
+ }),
111
207
  fareKey: defaultFare,
112
208
  fareKeyNameMap: fareKeyNameMap,
113
209
  transitFares: transitFares
@@ -123,9 +219,24 @@ function TripDetails({
123
219
  fareKeyNameMap: fareKeyNameMap,
124
220
  transitFares: transitFares
125
221
  });
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.
222
+ })), minTNCFare !== 0 && /*#__PURE__*/_react.default.createElement(S.TNCFare, null, /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
223
+ defaultMessage: defaultMessages["otpUi.TripDetails.tncFare"],
224
+ description: "Text showing the price paid to transportation network companies.",
225
+ id: "otpUi.TripDetails.tncFare",
226
+ values: {
227
+ companies:
228
+ /*#__PURE__*/
229
+ // S.TNCFareCompanies capitalizes the TNC company ID (e.g. "COMPANY")
230
+ // after it is converted to lowercase, so it renders as "Company".
231
+ _react.default.createElement(S.TNCFareCompanies, null, companies.toLowerCase()),
232
+ maxTNCFare: renderFare(tncCurrencyCode, maxTNCFare),
233
+ minTNCFare: renderFare(tncCurrencyCode, minTNCFare),
234
+ strong: boldText
235
+ }
236
+ })));
237
+ }
128
238
 
239
+ const departureDate = new Date(itinerary.startTime); // Compute calories burned.
129
240
 
130
241
  const {
131
242
  bikeDuration,
@@ -137,28 +248,36 @@ function TripDetails({
137
248
  const containsFlex = itinerary.legs.some(_coreUtils.default.itinerary.isFlex);
138
249
  const pickupBookingInfo = itinerary.legs.map(leg => leg.pickupBookingInfo).filter(info => !!info);
139
250
  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
251
  return /*#__PURE__*/_react.default.createElement(S.TripDetails, {
153
252
  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,
253
+ }, /*#__PURE__*/_react.default.createElement(S.TripDetailsHeader, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
254
+ defaultMessage: defaultMessages["otpUi.TripDetails.title"],
255
+ description: "Title (heading) text of the component.",
256
+ id: "otpUi.TripDetails.title"
257
+ })), /*#__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.
258
+ , {
259
+ description: DepartureDetails && /*#__PURE__*/_react.default.createElement(DepartureDetails, {
260
+ departureDate: departureDate
261
+ }),
156
262
  icon: /*#__PURE__*/_react.default.createElement(_CalendarAlt.CalendarAlt, {
157
263
  size: 17
158
264
  }),
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,
265
+ summary: /*#__PURE__*/_react.default.createElement(S.Timing, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
266
+ defaultMessage: defaultMessages["otpUi.TripDetails.departure"],
267
+ description: "Text showing the departure date/time for a trip.",
268
+ id: "otpUi.TripDetails.departure",
269
+ values: {
270
+ departureDate,
271
+ strong: boldText
272
+ }
273
+ }))
274
+ }), fare && /*#__PURE__*/_react.default.createElement(_tripDetail.default // Any custom description for the transit fare needs to be handled by the slot.
275
+ , {
276
+ description: FareDetails && /*#__PURE__*/_react.default.createElement(FareDetails, {
277
+ maxTNCFare: maxTNCFare,
278
+ minTNCFare: minTNCFare,
279
+ transitFares: transitFares
280
+ }),
162
281
  icon: /*#__PURE__*/_react.default.createElement(_MoneyBillAlt.MoneyBillAlt, {
163
282
  size: 17
164
283
  }),
@@ -167,14 +286,26 @@ function TripDetails({
167
286
  icon: /*#__PURE__*/_react.default.createElement(_Heartbeat.Heartbeat, {
168
287
  size: 17
169
288
  }),
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"), ".")
289
+ summary: /*#__PURE__*/_react.default.createElement(S.CaloriesSummary, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
290
+ defaultMessage: defaultMessages["otpUi.TripDetails.calories"],
291
+ description: "Text showing the number of calories for the walking and biking legs of a trip.",
292
+ id: "otpUi.TripDetails.calories",
293
+ values: {
294
+ calories: caloriesBurned,
295
+ strong: boldText
296
+ }
297
+ })),
298
+ description: CaloriesDetails && /*#__PURE__*/_react.default.createElement(CaloriesDetails, {
299
+ bikeSeconds: bikeDuration,
300
+ calories: caloriesBurned,
301
+ walkSeconds: walkDuration
302
+ })
176
303
  }), containsFlex && /*#__PURE__*/_react.default.createElement(_tripDetail.default, {
177
- summary: "This trip includes flexible routes.",
304
+ summary: /*#__PURE__*/_react.default.createElement(S.FlexSummary, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
305
+ defaultMessage: defaultMessages["otpUi.TripDetails.tripIncludesFlex"],
306
+ description: "Text stating that portions of the trip include a flex (on-demand) transit service.",
307
+ id: "otpUi.TripDetails.tripIncludesFlex"
308
+ })),
178
309
  icon: /*#__PURE__*/_react.default.createElement(_Route.Route, {
179
310
  size: 17
180
311
  })
@@ -183,7 +314,12 @@ function TripDetails({
183
314
  icon: /*#__PURE__*/_react.default.createElement(_PhoneVolume.PhoneVolume, {
184
315
  size: 17
185
316
  }),
186
- summary: `To take this route, ${callString(info)} ${advanceString(info)}.`,
317
+ summary: /*#__PURE__*/_react.default.createElement(S.FlexPickupSummary, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
318
+ defaultMessage: defaultMessages["otpUi.TripDetails.flexPickupMessage"],
319
+ description: "Instructions for booking and boarding the flex (on-demand) transit service.",
320
+ id: "otpUi.TripDetails.flexPickupMessage",
321
+ values: getFlexMessageValues(info)
322
+ })),
187
323
  description: info.pickupMessage
188
324
  })), dropOffBookingInfo && dropOffBookingInfo.map(info => /*#__PURE__*/_react.default.createElement(_tripDetail.default, {
189
325
  description: info.dropOffMessage,
@@ -193,74 +329,15 @@ function TripDetails({
193
329
  size: 17
194
330
  }),
195
331
  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)}.`
332
+ summary: /*#__PURE__*/_react.default.createElement(S.FlexDropOffSummary, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
333
+ defaultMessage: defaultMessages["otpUi.TripDetails.flexDropOffMessage"],
334
+ description: "Instructions for getting off the flex (on-demand) transit service.",
335
+ id: "otpUi.TripDetails.flexDropOffMessage",
336
+ values: getFlexMessageValues(info)
337
+ }))
197
338
  }))));
198
339
  }
199
340
 
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
341
  var _default = TripDetails; // Rename styled components for export
265
342
 
266
343
  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,CAAC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Z,GAA2B;AACzBG,EAAAA,SAAS,EAAE,IADc;AAEzBC,EAAAA,cAAc,EAAE,SAFS;AAGzBhB,EAAAA,cAAc,EAAE,EAHS;AAIzBkB,EAAAA,cAAc,EAAE,IAJS;AAKzBC,EAAAA,QAAQ,EAAE;AACRoD,IAAAA,EAAE,EAAE,IADI;AAERrB,IAAAA,cAAc,EAAE,iBAFR;AAGR;AACA+B,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","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","S","TransitFareSingle","display","map","toLowerCase","departureDate","Date","startTime","bikeDuration","caloriesBurned","walkDuration","calculatePhysicalActivity","containsFlex","some","isFlex","pickupBookingInfo","filter","dropOffBookingInfo","pickupMessage","dropOffMessage"],"mappings":";;;;;;;;;;AAAA;;AAGA;;AAEA;;A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B;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;;eAEc8B,W,EAEf","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\n role=\"button\"\n style={{ display: fareKeys.length > 1 ? \"list-item\" : \"\" }}\n >\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"}