@opentripplanner/trip-details 7.0.0 → 8.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.
Files changed (68) hide show
  1. package/esm/components/departure-date.js +42 -0
  2. package/esm/components/departure-date.js.map +1 -0
  3. package/esm/components/emissions.js +68 -0
  4. package/esm/components/emissions.js.map +1 -0
  5. package/esm/{fare-table.js → components/fare-table.js} +6 -6
  6. package/esm/components/fare-table.js.map +1 -0
  7. package/esm/components/fares.js +151 -0
  8. package/esm/components/fares.js.map +1 -0
  9. package/esm/components/flex-booking-info.js +51 -0
  10. package/esm/components/flex-booking-info.js.map +1 -0
  11. package/esm/components/time-active.js +69 -0
  12. package/esm/components/time-active.js.map +1 -0
  13. package/esm/index.js +40 -289
  14. package/esm/index.js.map +1 -1
  15. package/esm/trip-detail.js +4 -2
  16. package/esm/trip-detail.js.map +1 -1
  17. package/esm/types.js.map +1 -1
  18. package/lib/components/departure-date.d.ts +10 -0
  19. package/lib/components/departure-date.d.ts.map +1 -0
  20. package/lib/components/departure-date.js +51 -0
  21. package/lib/components/departure-date.js.map +1 -0
  22. package/lib/components/emissions.d.ts +8 -0
  23. package/lib/components/emissions.d.ts.map +1 -0
  24. package/lib/components/emissions.js +75 -0
  25. package/lib/components/emissions.js.map +1 -0
  26. package/lib/{fare-table.d.ts → components/fare-table.d.ts} +1 -1
  27. package/lib/components/fare-table.d.ts.map +1 -0
  28. package/lib/{fare-table.js → components/fare-table.js} +6 -6
  29. package/lib/components/fare-table.js.map +1 -0
  30. package/lib/components/fares.d.ts +10 -0
  31. package/lib/components/fares.d.ts.map +1 -0
  32. package/lib/components/fares.js +162 -0
  33. package/lib/components/fares.js.map +1 -0
  34. package/lib/components/flex-booking-info.d.ts +6 -0
  35. package/lib/components/flex-booking-info.d.ts.map +1 -0
  36. package/lib/components/flex-booking-info.js +47 -0
  37. package/lib/components/flex-booking-info.js.map +1 -0
  38. package/lib/components/time-active.d.ts +14 -0
  39. package/lib/components/time-active.d.ts.map +1 -0
  40. package/lib/components/time-active.js +79 -0
  41. package/lib/components/time-active.js.map +1 -0
  42. package/lib/index.d.ts +2 -2
  43. package/lib/index.d.ts.map +1 -1
  44. package/lib/index.js +27 -262
  45. package/lib/index.js.map +1 -1
  46. package/lib/trip-detail.d.ts +2 -1
  47. package/lib/trip-detail.d.ts.map +1 -1
  48. package/lib/trip-detail.js +4 -2
  49. package/lib/trip-detail.js.map +1 -1
  50. package/lib/types.d.ts +20 -19
  51. package/lib/types.d.ts.map +1 -1
  52. package/lib/types.js.map +1 -1
  53. package/package.json +3 -3
  54. package/src/TripDetails.story.tsx +26 -28
  55. package/src/__snapshots__/TripDetails.story.tsx.snap +108 -108
  56. package/src/components/departure-date.tsx +53 -0
  57. package/src/components/emissions.tsx +97 -0
  58. package/src/{fare-table.tsx → components/fare-table.tsx} +4 -4
  59. package/src/components/fares.tsx +205 -0
  60. package/src/components/flex-booking-info.tsx +57 -0
  61. package/src/components/time-active.tsx +90 -0
  62. package/src/index.tsx +28 -365
  63. package/src/trip-detail.tsx +8 -2
  64. package/src/types.ts +18 -17
  65. package/tsconfig.tsbuildinfo +1 -1
  66. package/esm/fare-table.js.map +0 -1
  67. package/lib/fare-table.d.ts.map +0 -1
  68. package/lib/fare-table.js.map +0 -1
package/esm/index.js CHANGED
@@ -1,17 +1,14 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import coreUtils from "@opentripplanner/core-utils";
3
1
  import React from "react";
4
- import { FormattedMessage, FormattedNumber } from "react-intl";
5
- import { CalendarAlt } from "@styled-icons/fa-solid/CalendarAlt";
6
- import { Heartbeat } from "@styled-icons/fa-solid/Heartbeat";
7
- import { MoneyBillAlt } from "@styled-icons/fa-solid/MoneyBillAlt";
8
- import { Leaf } from "@styled-icons/fa-solid/Leaf";
9
- import { Route } from "@styled-icons/fa-solid/Route";
2
+ import { FormattedMessage } from "react-intl";
10
3
  import { flatten } from "flat";
11
4
  import * as S from "./styled";
12
- import TripDetail from "./trip-detail";
13
- import FareLegTable from "./fare-table";
14
- import { boldText, renderFare } from "./utils";
5
+ import FareLegTable from "./components/fare-table";
6
+ import FlexBookingInfo from "./components/flex-booking-info";
7
+ import Emissions from "./components/emissions";
8
+ import Fares from "./components/fares";
9
+ import TimeActive, { DefaultTimeActiveDetails } from "./components/time-active";
10
+ import DepartureDate from "./components/departure-date";
11
+
15
12
  // Load the default messages.
16
13
  import defaultEnglishMessages from "../i18n/en-US.yml";
17
14
 
@@ -20,296 +17,50 @@ import defaultEnglishMessages from "../i18n/en-US.yml";
20
17
  // - the yaml loader for webpack returns a nested object,
21
18
  // - the yaml loader for jest returns messages with flattened ids.
22
19
  var defaultMessages = flatten(defaultEnglishMessages);
23
- function CO2DescriptionLink(contents) {
24
- return /*#__PURE__*/React.createElement("a", {
25
- href: "https://www.itf-oecd.org/sites/default/files/life-cycle-assessment-calculations-2020.xlsx",
26
- rel: "noopener noreferrer",
27
- target: "_blank"
28
- }, contents);
29
- }
30
- /**
31
- * Default rendering if no component is provided for the TimeActiveDetails
32
- * slot in the TripDetails component.
33
- */
34
- function DefaultTimeActiveDetails(_ref) {
35
- var bikeMinutes = _ref.bikeMinutes,
36
- walkMinutes = _ref.walkMinutes;
37
- return /*#__PURE__*/React.createElement(FormattedMessage, {
38
- defaultMessage: defaultMessages["otpUi.TripDetails.timeActiveDescription"],
39
- description: "Text describing the walking and biking durations of a trip.",
40
- id: "otpUi.TripDetails.timeActiveDescription",
41
- values: {
42
- bikeMinutes: bikeMinutes,
43
- strong: boldText,
44
- walkMinutes: walkMinutes
45
- }
46
- });
20
+ function cn(className, arg1) {
21
+ return className ? "".concat(className, " ").concat(arg1) : arg1;
47
22
  }
48
23
 
49
24
  /**
50
25
  * Renders trip details such as departure instructions, fare amount, and minutes active.
51
26
  */
52
- export function TripDetails(_ref2) {
53
- var _ref2$className = _ref2.className,
54
- className = _ref2$className === void 0 ? "" : _ref2$className,
55
- co2Config = _ref2.co2Config,
56
- defaultFareType = _ref2.defaultFareType,
57
- _ref2$DepartureDetail = _ref2.DepartureDetails,
58
- DepartureDetails = _ref2$DepartureDetail === void 0 ? null : _ref2$DepartureDetail,
59
- _ref2$displayTimeActi = _ref2.displayTimeActive,
60
- displayTimeActive = _ref2$displayTimeActi === void 0 ? true : _ref2$displayTimeActi,
61
- _ref2$FareDetails = _ref2.FareDetails,
62
- FareDetails = _ref2$FareDetails === void 0 ? null : _ref2$FareDetails,
63
- fareDetailsLayout = _ref2.fareDetailsLayout,
64
- _ref2$fareKeyNameMap = _ref2.fareKeyNameMap,
65
- fareKeyNameMap = _ref2$fareKeyNameMap === void 0 ? {} : _ref2$fareKeyNameMap,
66
- itinerary = _ref2.itinerary,
67
- showApproximateMinutesActive = _ref2.showApproximateMinutesActive,
68
- _ref2$TimeActiveDetai = _ref2.TimeActiveDetails,
69
- TimeActiveDetails = _ref2$TimeActiveDetai === void 0 ? DefaultTimeActiveDetails : _ref2$TimeActiveDetai;
70
- // process the transit fare
71
- var fareResult = coreUtils.itinerary.calculateTncFares(itinerary);
72
- var currencyCode = fareResult.currencyCode,
73
- maxTNCFare = fareResult.maxTNCFare,
74
- minTNCFare = fareResult.minTNCFare;
75
- var _itinerary$legs$reduc = itinerary.legs.reduce(function (prev, leg) {
76
- if (leg.rideHailingEstimate) {
77
- prev.companies = leg.rideHailingEstimate.provider.id;
78
- }
79
- if (leg.fareProducts) {
80
- leg.fareProducts.forEach(function (fp) {
81
- var _fp$product$medium, _fp$product$riderCate;
82
- var mediumId = (_fp$product$medium = fp.product.medium) === null || _fp$product$medium === void 0 ? void 0 : _fp$product$medium.id;
83
- var riderCategoryId = (_fp$product$riderCate = fp.product.riderCategory) === null || _fp$product$riderCate === void 0 ? void 0 : _fp$product$riderCate.id;
84
- if (!prev.fareTypes.find(function (ft) {
85
- return ft.mediumId === mediumId && ft.riderCategoryId === riderCategoryId;
86
- })) {
87
- prev.fareTypes.push({
88
- mediumId: mediumId,
89
- riderCategoryId: riderCategoryId
90
- });
91
- }
92
- });
93
- }
94
- return prev;
95
- }, {
96
- companies: "",
97
- fareTypes: []
98
- }),
99
- companies = _itinerary$legs$reduc.companies,
100
- fareTypes = _itinerary$legs$reduc.fareTypes;
101
- var fare;
102
- if (fareTypes.length > 0 && defaultFareType) {
103
- var _defaultFareTotal$cur;
104
- var defaultFareTotal = coreUtils.itinerary.getItineraryCost(itinerary.legs, defaultFareType.mediumId, defaultFareType.riderCategoryId);
105
- // Depending on if there are additional fares to display either render a <span> or a <details>
106
- var TransitFareWrapper = fareTypes.length > 1 ? S.TransitFare : S.TransitFareSingle;
107
- var fareNameFallback = /*#__PURE__*/React.createElement(FormattedMessage, {
108
- defaultMessage: defaultMessages["otpUi.TripDetails.transitFare"],
109
- description: "Text showing the price of tickets on public transportation.",
110
- id: "otpUi.TripDetails.transitFare"
111
- });
112
- fare = defaultFareTotal !== undefined && /*#__PURE__*/React.createElement(S.Fare, null, /*#__PURE__*/React.createElement(TransitFareWrapper, null, /*#__PURE__*/React.createElement("summary", {
113
- style: {
114
- display: fareTypes.length > 1 ? "list-item" : ""
115
- }
116
- }, /*#__PURE__*/React.createElement(FormattedMessage, {
117
- defaultMessage: defaultMessages["otpUi.TripDetails.transitFareEntry"],
118
- description: "Text showing the price of tickets on public transportation.",
119
- id: "otpUi.TripDetails.transitFareEntry",
120
- values: {
121
- name: fareKeyNameMap[defaultFareType.headerKey] || fareNameFallback,
122
- strong: boldText,
123
- value: renderFare(((_defaultFareTotal$cur = defaultFareTotal.currency) === null || _defaultFareTotal$cur === void 0 ? void 0 : _defaultFareTotal$cur.code) || "USD", defaultFareTotal === null || defaultFareTotal === void 0 ? void 0 : defaultFareTotal.amount)
124
- }
125
- })), fareDetailsLayout ?
126
- /*#__PURE__*/
127
- // Show full ƒare details by leg
128
- React.createElement(FareLegTable, {
129
- layout: fareDetailsLayout,
130
- legs: itinerary.legs
131
- }) :
132
- // Just show the fares for each payment type
133
- fareTypes.map(function (fareType) {
134
- var _defaultFareTotal$cur2, _defaultFareTotal$cur3;
135
- // Don't show the default fare twice!
136
- if (fareType) {
137
- return null;
138
- }
139
- return /*#__PURE__*/React.createElement(FormattedMessage, {
140
- defaultMessage: defaultMessages["otpUi.TripDetails.transitFareEntry"],
141
- description: "Text showing the price of tickets on public transportation.",
142
- id: "otpUi.TripDetails.transitFareEntry",
143
- key: Object.values(fareType).join("-"),
144
- values: {
145
- name: fareKeyNameMap[defaultFareType.headerKey] || fareNameFallback,
146
- strong: boldText,
147
- value: renderFare(((_defaultFareTotal$cur2 = defaultFareTotal.currency) === null || _defaultFareTotal$cur2 === void 0 ? void 0 : _defaultFareTotal$cur2.code) || "USD", (defaultFareTotal === null || defaultFareTotal === void 0 ? void 0 : defaultFareTotal.amount) / (defaultFareTotal === null || defaultFareTotal === void 0 || (_defaultFareTotal$cur3 = defaultFareTotal.currency) === null || _defaultFareTotal$cur3 === void 0 ? void 0 : _defaultFareTotal$cur3.digits))
148
- }
149
- });
150
- })));
151
- }
152
- var tncFare = minTNCFare !== 0 && /*#__PURE__*/React.createElement(S.Fare, null, /*#__PURE__*/React.createElement(S.TNCFare, null, /*#__PURE__*/React.createElement(FormattedMessage, {
153
- defaultMessage: defaultMessages["otpUi.TripDetails.tncFare"],
154
- description: "Text showing the price paid to transportation network companies.",
155
- id: "otpUi.TripDetails.tncFare",
156
- values: {
157
- companies:
158
- /*#__PURE__*/
159
- // S.TNCFareCompanies capitalizes the TNC company ID (e.g. "COMPANY")
160
- // after it is converted to lowercase, so it renders as "Company".
161
- React.createElement(S.TNCFareCompanies, null, companies.toLowerCase()),
162
- maxTNCFare: renderFare(currencyCode, maxTNCFare),
163
- minTNCFare: renderFare(currencyCode, minTNCFare),
164
- strong: boldText
165
- }
166
- })));
167
- var departureDate = new Date(itinerary.startTime);
168
-
169
- // Compute total time spent active.
170
-
171
- // TODO: separate into two reducers
172
- var walkDurationSeconds = 0;
173
- var bikeDurationSeconds = 0;
174
- itinerary.legs.forEach(function (leg) {
175
- if (leg.mode.startsWith("WALK")) walkDurationSeconds += leg.duration;
176
- if (leg.mode.startsWith("BICYCLE")) bikeDurationSeconds += leg.duration;
177
- });
178
- var bikeMinutes = Math.round(bikeDurationSeconds / 60);
179
- var walkMinutes = Math.round(walkDurationSeconds / 60);
180
- var minutesActive = bikeMinutes + walkMinutes;
181
-
182
- // Calculate CO₂ if it's not provided by the itinerary
183
- var co2 = itinerary.co2 || (co2Config === null || co2Config === void 0 ? void 0 : co2Config.enabled) && coreUtils.itinerary.calculateEmissions(itinerary, co2Config === null || co2Config === void 0 ? void 0 : co2Config.carbonIntensity, co2Config === null || co2Config === void 0 ? void 0 : co2Config.units);
184
-
185
- // Parse flex info and generate appropriate strings
186
- var containsFlex = itinerary.legs.some(coreUtils.itinerary.isFlex);
187
- var pickupBookingInfo = itinerary.legs.map(function (leg) {
188
- return leg.pickupBookingInfo;
189
- }).filter(function (info) {
190
- return !!info;
191
- });
192
- var dropOffBookingInfo = itinerary.legs.map(function (leg) {
193
- return leg.dropOffBookingInfo;
194
- }).filter(function (info) {
195
- return !!info;
196
- });
197
- var totalDistance = itinerary.legs.reduce(function (total, leg) {
198
- return total + leg.distance;
199
- }, 0);
27
+ export function TripDetails(_ref) {
28
+ var _ref$className = _ref.className,
29
+ className = _ref$className === void 0 ? "" : _ref$className,
30
+ co2Config = _ref.co2Config,
31
+ _ref$DepartureDetails = _ref.DepartureDetails,
32
+ DepartureDetails = _ref$DepartureDetails === void 0 ? null : _ref$DepartureDetails,
33
+ _ref$FareDetails = _ref.FareDetails,
34
+ FareDetails = _ref$FareDetails === void 0 ? null : _ref$FareDetails,
35
+ fareConfig = _ref.fareConfig,
36
+ itinerary = _ref.itinerary,
37
+ showApproximateMinutesActive = _ref.showApproximateMinutesActive,
38
+ _ref$TimeActiveDetail = _ref.TimeActiveDetails,
39
+ TimeActiveDetails = _ref$TimeActiveDetail === void 0 ? DefaultTimeActiveDetails : _ref$TimeActiveDetail;
200
40
  return /*#__PURE__*/React.createElement(S.TripDetails, {
201
- className: className
41
+ className: cn(className, "trip-details")
202
42
  }, /*#__PURE__*/React.createElement(S.TripDetailsHeader, {
203
43
  id: "trip-details-header"
204
44
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
205
45
  defaultMessage: defaultMessages["otpUi.TripDetails.title"],
206
46
  description: "Title (heading) text of the component.",
207
47
  id: "otpUi.TripDetails.title"
208
- })), /*#__PURE__*/React.createElement(S.TripDetailsBody, null, /*#__PURE__*/React.createElement(TripDetail
209
- // Any custom description for the Departure message needs to be handled by the slot.
210
- , {
211
- description: DepartureDetails && /*#__PURE__*/React.createElement(DepartureDetails, {
212
- departureDate: departureDate
213
- }),
214
- icon: /*#__PURE__*/React.createElement(CalendarAlt, {
215
- size: 17
216
- }),
217
- summary: /*#__PURE__*/React.createElement(S.Timing, null, /*#__PURE__*/React.createElement(FormattedMessage, {
218
- defaultMessage: defaultMessages["otpUi.TripDetails.departure"],
219
- description: "Text showing the departure date/time for a trip.",
220
- id: "otpUi.TripDetails.departure",
221
- values: {
222
- departureDate: departureDate,
223
- strong: boldText
224
- }
225
- }))
226
- }), !!fare && /*#__PURE__*/React.createElement(TripDetail
227
- // Any custom description for the transit fare needs to be handled by the slot.
228
- , {
229
- description: FareDetails && /*#__PURE__*/React.createElement(FareDetails, {
230
- legs: itinerary.legs,
231
- maxTNCFare: maxTNCFare,
232
- minTNCFare: minTNCFare
233
- }),
234
- icon: /*#__PURE__*/React.createElement(MoneyBillAlt, {
235
- size: 17
236
- }),
237
- summary: fare
238
- }), tncFare && /*#__PURE__*/React.createElement(TripDetail
239
- // Any custom description for the transit fare needs to be handled by the slot.
240
- , {
241
- description: FareDetails && /*#__PURE__*/React.createElement(FareDetails, {
242
- legs: itinerary.legs,
243
- maxTNCFare: maxTNCFare,
244
- minTNCFare: minTNCFare
245
- }),
246
- icon: /*#__PURE__*/React.createElement(MoneyBillAlt, {
247
- size: 17
248
- }),
249
- summary: tncFare
250
- }), displayTimeActive && minutesActive > 0 && /*#__PURE__*/React.createElement(TripDetail, {
251
- icon: /*#__PURE__*/React.createElement(Heartbeat, {
252
- size: 17
253
- }),
254
- summary: /*#__PURE__*/React.createElement(FormattedMessage, {
255
- defaultMessage: defaultMessages["otpUi.TripDetails.minutesActive"],
256
- description: "Text showing the number of minutes spent walking or biking throughout trip.",
257
- id: "otpUi.TripDetails.minutesActive",
258
- values: {
259
- approximatePrefix: showApproximateMinutesActive,
260
- minutes: minutesActive,
261
- strong: boldText
262
- }
263
- }),
264
- description: TimeActiveDetails && /*#__PURE__*/React.createElement(TimeActiveDetails, {
265
- bikeMinutes: bikeMinutes,
266
- walkMinutes: walkMinutes
267
- })
268
- }), co2 > 0 && (co2Config === null || co2Config === void 0 ? void 0 : co2Config.enabled) && /*#__PURE__*/React.createElement(TripDetail, {
269
- icon: /*#__PURE__*/React.createElement(Leaf, {
270
- size: 17
271
- }),
272
- summary: /*#__PURE__*/React.createElement(S.CO2Summary, null, /*#__PURE__*/React.createElement(FormattedMessage, {
273
- defaultMessage: defaultMessages["otpUi.TripDetails.co2"],
274
- description: "Text showing the quantity of CO\u2082 emitted by this trip.",
275
- id: "otpUi.TripDetails.co2",
276
- values: {
277
- co2: /*#__PURE__*/React.createElement(FormattedNumber, {
278
- value: Math.round(co2)
279
- // eslint-disable-next-line react/style-prop-object
280
- ,
281
- style: "unit",
282
- unit: (co2Config === null || co2Config === void 0 ? void 0 : co2Config.units) || "gram",
283
- unitDisplay: "narrow"
284
- }),
285
- strong: boldText
286
- }
287
- })),
288
- description: /*#__PURE__*/React.createElement(FormattedMessage, {
289
- defaultMessage: defaultMessages["otpUi.TripDetails.co2description"],
290
- description: "Text explaining how the CO\u2082 emissions are calculated.",
291
- id: "otpUi.TripDetails.co2description",
292
- values: {
293
- link: CO2DescriptionLink,
294
- totalDistance: totalDistance
295
- }
296
- })
297
- }), containsFlex && /*#__PURE__*/React.createElement(TripDetail, {
298
- summary: /*#__PURE__*/React.createElement(S.FlexSummary, null, /*#__PURE__*/React.createElement(FormattedMessage, {
299
- defaultMessage: defaultMessages["otpUi.TripDetails.tripIncludesFlex"],
300
- description: "Text stating that portions of the trip include a flex (on-demand) transit service.",
301
- id: "otpUi.TripDetails.tripIncludesFlex",
302
- values: {
303
- extraMessage: _toConsumableArray(new Set([].concat(_toConsumableArray(pickupBookingInfo.map(function (info) {
304
- return info.message;
305
- })), _toConsumableArray(dropOffBookingInfo.map(function (info) {
306
- return info.message;
307
- }))))).join(" ")
308
- }
309
- })),
310
- icon: /*#__PURE__*/React.createElement(Route, {
311
- size: 17
312
- })
48
+ })), /*#__PURE__*/React.createElement(S.TripDetailsBody, null, /*#__PURE__*/React.createElement(DepartureDate, {
49
+ itinerary: itinerary,
50
+ DepartureDetails: DepartureDetails
51
+ }), /*#__PURE__*/React.createElement(Fares, {
52
+ itinerary: itinerary,
53
+ fareConfig: fareConfig,
54
+ FareDetails: FareDetails
55
+ }), /*#__PURE__*/React.createElement(TimeActive, {
56
+ itinerary: itinerary,
57
+ TimeActiveDetails: TimeActiveDetails,
58
+ showApproximateMinutesActive: showApproximateMinutesActive
59
+ }), /*#__PURE__*/React.createElement(FlexBookingInfo, {
60
+ itinerary: itinerary
61
+ }), /*#__PURE__*/React.createElement(Emissions, {
62
+ itinerary: itinerary,
63
+ co2Config: co2Config
313
64
  })));
314
65
  }
315
66
  export default TripDetails;
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["coreUtils","React","FormattedMessage","FormattedNumber","CalendarAlt","Heartbeat","MoneyBillAlt","Leaf","Route","flatten","S","TripDetail","FareLegTable","boldText","renderFare","defaultEnglishMessages","defaultMessages","CO2DescriptionLink","contents","createElement","href","rel","target","DefaultTimeActiveDetails","_ref","bikeMinutes","walkMinutes","defaultMessage","description","id","values","strong","TripDetails","_ref2","_ref2$className","className","co2Config","defaultFareType","_ref2$DepartureDetail","DepartureDetails","_ref2$displayTimeActi","displayTimeActive","_ref2$FareDetails","FareDetails","fareDetailsLayout","_ref2$fareKeyNameMap","fareKeyNameMap","itinerary","showApproximateMinutesActive","_ref2$TimeActiveDetai","TimeActiveDetails","fareResult","calculateTncFares","currencyCode","maxTNCFare","minTNCFare","_itinerary$legs$reduc","legs","reduce","prev","leg","rideHailingEstimate","companies","provider","fareProducts","forEach","fp","_fp$product$medium","_fp$product$riderCate","mediumId","product","medium","riderCategoryId","riderCategory","fareTypes","find","ft","push","fare","length","_defaultFareTotal$cur","defaultFareTotal","getItineraryCost","TransitFareWrapper","TransitFare","TransitFareSingle","fareNameFallback","undefined","Fare","style","display","name","headerKey","value","currency","code","amount","layout","map","fareType","_defaultFareTotal$cur2","_defaultFareTotal$cur3","key","Object","join","digits","tncFare","TNCFare","TNCFareCompanies","toLowerCase","departureDate","Date","startTime","walkDurationSeconds","bikeDurationSeconds","mode","startsWith","duration","Math","round","minutesActive","co2","enabled","calculateEmissions","carbonIntensity","units","containsFlex","some","isFlex","pickupBookingInfo","filter","info","dropOffBookingInfo","totalDistance","total","distance","TripDetailsHeader","TripDetailsBody","icon","size","summary","Timing","approximatePrefix","minutes","CO2Summary","unit","unitDisplay","link","FlexSummary","extraMessage","_toConsumableArray","Set","concat","message","Styled"],"sources":["../src/index.tsx"],"sourcesContent":["import coreUtils from \"@opentripplanner/core-utils\";\nimport { FareProductSelector } from \"@opentripplanner/types\";\nimport React, { ReactElement, ReactNode } from \"react\";\nimport { FormattedMessage, FormattedNumber } from \"react-intl\";\nimport { CalendarAlt } from \"@styled-icons/fa-solid/CalendarAlt\";\nimport { Heartbeat } from \"@styled-icons/fa-solid/Heartbeat\";\nimport { MoneyBillAlt } from \"@styled-icons/fa-solid/MoneyBillAlt\";\nimport { Leaf } from \"@styled-icons/fa-solid/Leaf\";\nimport { Route } from \"@styled-icons/fa-solid/Route\";\nimport { flatten } from \"flat\";\nimport * as S from \"./styled\";\nimport TripDetail from \"./trip-detail\";\nimport FareLegTable from \"./fare-table\";\nimport { boldText, renderFare } from \"./utils\";\n\nimport { TimeActiveDetailsProps, TripDetailsProps } 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\nfunction CO2DescriptionLink(contents: ReactNode): ReactElement {\n return (\n <a\n href=\"https://www.itf-oecd.org/sites/default/files/life-cycle-assessment-calculations-2020.xlsx\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {contents}\n </a>\n );\n}\n/**\n * Default rendering if no component is provided for the TimeActiveDetails\n * slot in the TripDetails component.\n */\nfunction DefaultTimeActiveDetails({\n bikeMinutes,\n walkMinutes\n}: TimeActiveDetailsProps): ReactElement {\n return (\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.timeActiveDescription\"]\n }\n description=\"Text describing the walking and biking durations of a trip.\"\n id=\"otpUi.TripDetails.timeActiveDescription\"\n values={{\n bikeMinutes,\n strong: boldText,\n walkMinutes\n }}\n />\n );\n}\n\n/**\n * Renders trip details such as departure instructions, fare amount, and minutes active.\n */\nexport function TripDetails({\n className = \"\",\n co2Config,\n defaultFareType,\n DepartureDetails = null,\n displayTimeActive = true,\n FareDetails = null,\n fareDetailsLayout,\n fareKeyNameMap = {},\n itinerary,\n showApproximateMinutesActive,\n TimeActiveDetails = DefaultTimeActiveDetails\n}: TripDetailsProps): ReactElement {\n // process the transit fare\n const fareResult = coreUtils.itinerary.calculateTncFares(itinerary);\n const { currencyCode, maxTNCFare, minTNCFare } = fareResult;\n\n const { companies, fareTypes } = itinerary.legs.reduce<{\n companies: string;\n fareTypes: FareProductSelector[];\n }>(\n (prev, leg) => {\n if (leg.rideHailingEstimate) {\n prev.companies = leg.rideHailingEstimate.provider.id;\n }\n\n if (leg.fareProducts) {\n leg.fareProducts.forEach(fp => {\n const mediumId = fp.product.medium?.id;\n const riderCategoryId = fp.product.riderCategory?.id;\n if (\n !prev.fareTypes.find(\n ft =>\n ft.mediumId === mediumId &&\n ft.riderCategoryId === riderCategoryId\n )\n ) {\n prev.fareTypes.push({ mediumId, riderCategoryId });\n }\n });\n }\n return prev;\n },\n { companies: \"\", fareTypes: [] }\n );\n\n let fare;\n if (fareTypes.length > 0 && defaultFareType) {\n const defaultFareTotal = coreUtils.itinerary.getItineraryCost(\n itinerary.legs,\n defaultFareType.mediumId,\n defaultFareType.riderCategoryId\n );\n // Depending on if there are additional fares to display either render a <span> or a <details>\n const TransitFareWrapper =\n fareTypes.length > 1 ? S.TransitFare : S.TransitFareSingle;\n\n const fareNameFallback = (\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.transitFare\"]}\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFare\"\n />\n );\n\n fare = defaultFareTotal !== undefined && (\n <S.Fare>\n <TransitFareWrapper>\n <summary style={{ display: fareTypes.length > 1 ? \"list-item\" : \"\" }}>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.transitFareEntry\"]\n }\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFareEntry\"\n values={{\n name:\n fareKeyNameMap[defaultFareType.headerKey] || fareNameFallback,\n strong: boldText,\n value: renderFare(\n defaultFareTotal.currency?.code || \"USD\",\n defaultFareTotal?.amount\n )\n }}\n />\n </summary>\n {fareDetailsLayout ? (\n // Show full ƒare details by leg\n <FareLegTable layout={fareDetailsLayout} legs={itinerary.legs} />\n ) : (\n // Just show the fares for each payment type\n fareTypes.map(fareType => {\n // Don't show the default fare twice!\n if (fareType) {\n return null;\n }\n return (\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.transitFareEntry\"]\n }\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFareEntry\"\n key={Object.values(fareType).join(\"-\")}\n values={{\n name:\n fareKeyNameMap[defaultFareType.headerKey] ||\n fareNameFallback,\n strong: boldText,\n value: renderFare(\n defaultFareTotal.currency?.code || \"USD\",\n defaultFareTotal?.amount /\n defaultFareTotal?.currency?.digits\n )\n }}\n />\n );\n })\n )}\n </TransitFareWrapper>\n </S.Fare>\n );\n }\n const tncFare = minTNCFare !== 0 && (\n <S.Fare>\n <S.TNCFare>\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>{companies.toLowerCase()}</S.TNCFareCompanies>\n ),\n maxTNCFare: renderFare(currencyCode, maxTNCFare),\n minTNCFare: renderFare(currencyCode, minTNCFare),\n strong: boldText\n }}\n />\n </S.TNCFare>\n </S.Fare>\n );\n\n const departureDate = new Date(itinerary.startTime);\n\n // Compute total time spent active.\n\n // TODO: separate into two reducers\n let walkDurationSeconds = 0;\n let bikeDurationSeconds = 0;\n itinerary.legs.forEach(leg => {\n if (leg.mode.startsWith(\"WALK\")) walkDurationSeconds += leg.duration;\n if (leg.mode.startsWith(\"BICYCLE\")) bikeDurationSeconds += leg.duration;\n });\n const bikeMinutes = Math.round(bikeDurationSeconds / 60);\n const walkMinutes = Math.round(walkDurationSeconds / 60);\n const minutesActive = bikeMinutes + walkMinutes;\n\n // Calculate CO₂ if it's not provided by the itinerary\n const co2 =\n itinerary.co2 ||\n (co2Config?.enabled &&\n coreUtils.itinerary.calculateEmissions(\n itinerary,\n co2Config?.carbonIntensity,\n co2Config?.units\n ));\n\n // Parse flex info and generate appropriate strings\n const containsFlex = itinerary.legs.some(coreUtils.itinerary.isFlex);\n const pickupBookingInfo = itinerary.legs\n .map(leg => leg.pickupBookingInfo)\n .filter(info => !!info);\n const dropOffBookingInfo = itinerary.legs\n .map(leg => leg.dropOffBookingInfo)\n .filter(info => !!info);\n const totalDistance = itinerary.legs.reduce(\n (total, leg) => total + leg.distance,\n 0\n );\n\n return (\n <S.TripDetails className={className}>\n {/* this can be presentation as S.TripDetails is already labeled by this */}\n <S.TripDetailsHeader id=\"trip-details-header\">\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 legs={itinerary.legs}\n maxTNCFare={maxTNCFare}\n minTNCFare={minTNCFare}\n />\n )\n }\n icon={<MoneyBillAlt size={17} />}\n summary={fare}\n />\n )}\n {tncFare && (\n <TripDetail\n // Any custom description for the transit fare needs to be handled by the slot.\n description={\n FareDetails && (\n <FareDetails\n legs={itinerary.legs}\n maxTNCFare={maxTNCFare}\n minTNCFare={minTNCFare}\n />\n )\n }\n icon={<MoneyBillAlt size={17} />}\n summary={tncFare}\n />\n )}\n {displayTimeActive && minutesActive > 0 && (\n <TripDetail\n icon={<Heartbeat size={17} />}\n summary={\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.minutesActive\"]\n }\n description=\"Text showing the number of minutes spent walking or biking throughout trip.\"\n id=\"otpUi.TripDetails.minutesActive\"\n values={{\n approximatePrefix: showApproximateMinutesActive,\n minutes: minutesActive,\n strong: boldText\n }}\n />\n }\n description={\n TimeActiveDetails && (\n <TimeActiveDetails\n bikeMinutes={bikeMinutes}\n walkMinutes={walkMinutes}\n />\n )\n }\n />\n )}\n {co2 > 0 && co2Config?.enabled && (\n <TripDetail\n icon={<Leaf size={17} />}\n summary={\n <S.CO2Summary>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.co2\"]}\n description=\"Text showing the quantity of CO₂ emitted by this trip.\"\n id=\"otpUi.TripDetails.co2\"\n values={{\n co2: (\n <FormattedNumber\n value={Math.round(co2)}\n // eslint-disable-next-line react/style-prop-object\n style=\"unit\"\n unit={co2Config?.units || \"gram\"}\n unitDisplay=\"narrow\"\n />\n ),\n strong: boldText\n }}\n />\n </S.CO2Summary>\n }\n description={\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.co2description\"]\n }\n description=\"Text explaining how the CO₂ emissions are calculated.\"\n id=\"otpUi.TripDetails.co2description\"\n values={{\n link: CO2DescriptionLink,\n totalDistance\n }}\n />\n }\n />\n )}\n {containsFlex && (\n <TripDetail\n summary={\n <S.FlexSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.tripIncludesFlex\"]\n }\n description=\"Text stating that portions of the trip include a flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.tripIncludesFlex\"\n values={{\n extraMessage: [\n ...new Set([\n ...pickupBookingInfo.map(info => info.message),\n ...dropOffBookingInfo.map(info => info.message)\n ])\n ].join(\" \")\n }}\n />\n </S.FlexSummary>\n }\n icon={<Route size={17} />}\n />\n )}\n </S.TripDetailsBody>\n </S.TripDetails>\n );\n}\n\nexport default TripDetails;\n\n// Rename styled components for export.\nexport { S as Styled, FareLegTable };\n"],"mappings":";AAAA,OAAOA,SAAS,MAAM,6BAA6B;AAEnD,OAAOC,KAAK,MAAmC,OAAO;AACtD,SAASC,gBAAgB,EAAEC,eAAe,QAAQ,YAAY;AAC9D,SAASC,WAAW,QAAQ,oCAAoC;AACh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rCC,MAAM,EAAE;QACNqH,IAAI,EAAElI,kBAAkB;QACxBoH,aAAa,EAAbA;MACF;IAAE,CACH;EACF,CACF,CACF,EACAP,YAAY,iBACX7H,KAAA,CAAAkB,aAAA,CAACR,UAAU;IACTiI,OAAO,eACL3I,KAAA,CAAAkB,aAAA,CAACT,CAAC,CAAC0I,WAAW,qBACZnJ,KAAA,CAAAkB,aAAA,CAACjB,gBAAgB;MACfyB,cAAc,EACZX,eAAe,CAAC,oCAAoC,CACrD;MACDY,WAAW,EAAC,oFAAoF;MAChGC,EAAE,EAAC,oCAAoC;MACvCC,MAAM,EAAE;QACNuH,YAAY,EAAEC,kBAAA,CACT,IAAIC,GAAG,IAAAC,MAAA,CAAAF,kBAAA,CACLrB,iBAAiB,CAAC/B,GAAG,CAAC,UAAAiC,IAAI;UAAA,OAAIA,IAAI,CAACsB,OAAO;QAAA,EAAC,GAAAH,kBAAA,CAC3ClB,kBAAkB,CAAClC,GAAG,CAAC,UAAAiC,IAAI;UAAA,OAAIA,IAAI,CAACsB,OAAO;QAAA,EAAC,EAChD,CAAC,EACFjD,IAAI,CAAC,GAAG;MACZ;IAAE,CACH,CACY,CAChB;IACDkC,IAAI,eAAEzI,KAAA,CAAAkB,aAAA,CAACX,KAAK;MAACmI,IAAI,EAAE;IAAG,CAAE;EAAE,CAC3B,CAEc,CACN,CAAC;AAEpB;AAEA,eAAe3G,WAAW;;AAE1B;AACA,SAAStB,CAAC,IAAIgJ,MAAM,EAAE9I,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["React","FormattedMessage","flatten","S","FareLegTable","FlexBookingInfo","Emissions","Fares","TimeActive","DefaultTimeActiveDetails","DepartureDate","defaultEnglishMessages","defaultMessages","cn","className","arg1","concat","TripDetails","_ref","_ref$className","co2Config","_ref$DepartureDetails","DepartureDetails","_ref$FareDetails","FareDetails","fareConfig","itinerary","showApproximateMinutesActive","_ref$TimeActiveDetail","TimeActiveDetails","createElement","TripDetailsHeader","id","defaultMessage","description","TripDetailsBody","Styled"],"sources":["../src/index.tsx"],"sourcesContent":["import React, { ReactElement } from \"react\";\nimport { FormattedMessage } from \"react-intl\";\nimport { flatten } from \"flat\";\nimport * as S from \"./styled\";\nimport FareLegTable from \"./components/fare-table\";\nimport { TripDetailsProps } from \"./types\";\nimport FlexBookingInfo from \"./components/flex-booking-info\";\nimport Emissions from \"./components/emissions\";\nimport Fares from \"./components/fares\";\nimport TimeActive, { DefaultTimeActiveDetails } from \"./components/time-active\";\nimport DepartureDate from \"./components/departure-date\";\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\nfunction cn(className: string, arg1: string): string {\n return className ? `${className} ${arg1}` : arg1;\n}\n\n/**\n * Renders trip details such as departure instructions, fare amount, and minutes active.\n */\nexport function TripDetails({\n className = \"\",\n co2Config,\n DepartureDetails = null,\n FareDetails = null,\n fareConfig,\n itinerary,\n showApproximateMinutesActive,\n TimeActiveDetails = DefaultTimeActiveDetails\n}: TripDetailsProps): ReactElement {\n return (\n <S.TripDetails className={cn(className, \"trip-details\")}>\n {/* this can be presentation as S.TripDetails is already labeled by this */}\n <S.TripDetailsHeader id=\"trip-details-header\">\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 <DepartureDate\n itinerary={itinerary}\n DepartureDetails={DepartureDetails}\n />\n <Fares\n itinerary={itinerary}\n fareConfig={fareConfig}\n FareDetails={FareDetails}\n />\n <TimeActive\n itinerary={itinerary}\n TimeActiveDetails={TimeActiveDetails}\n showApproximateMinutesActive={showApproximateMinutesActive}\n />\n <FlexBookingInfo itinerary={itinerary} />\n <Emissions itinerary={itinerary} co2Config={co2Config} />\n </S.TripDetailsBody>\n </S.TripDetails>\n );\n}\n\nexport default TripDetails;\n\n// Rename styled components for export.\nexport { S as Styled, FareLegTable };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAwB,OAAO;AAC3C,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,OAAO,QAAQ,MAAM;AAC9B,OAAO,KAAKC,CAAC,MAAM,UAAU;AAC7B,OAAOC,YAAY,MAAM,yBAAyB;AAElD,OAAOC,eAAe,MAAM,gCAAgC;AAC5D,OAAOC,SAAS,MAAM,wBAAwB;AAC9C,OAAOC,KAAK,MAAM,oBAAoB;AACtC,OAAOC,UAAU,IAAIC,wBAAwB,QAAQ,0BAA0B;AAC/E,OAAOC,aAAa,MAAM,6BAA6B;;AAEvD;AACA,OAAOC,sBAAsB,MAAM,mBAAmB;;AAEtD;AACA;AACA;AACA;AACA,IAAMC,eAAuC,GAAGV,OAAO,CAACS,sBAAsB,CAAC;AAE/E,SAASE,EAAEA,CAACC,SAAiB,EAAEC,IAAY,EAAU;EACnD,OAAOD,SAAS,MAAAE,MAAA,CAAMF,SAAS,OAAAE,MAAA,CAAID,IAAI,IAAKA,IAAI;AAClD;;AAEA;AACA;AACA;AACA,OAAO,SAASE,WAAWA,CAAAC,IAAA,EASQ;EAAA,IAAAC,cAAA,GAAAD,IAAA,CARjCJ,SAAS;IAATA,SAAS,GAAAK,cAAA,cAAG,EAAE,GAAAA,cAAA;IACdC,SAAS,GAAAF,IAAA,CAATE,SAAS;IAAAC,qBAAA,GAAAH,IAAA,CACTI,gBAAgB;IAAhBA,gBAAgB,GAAAD,qBAAA,cAAG,IAAI,GAAAA,qBAAA;IAAAE,gBAAA,GAAAL,IAAA,CACvBM,WAAW;IAAXA,WAAW,GAAAD,gBAAA,cAAG,IAAI,GAAAA,gBAAA;IAClBE,UAAU,GAAAP,IAAA,CAAVO,UAAU;IACVC,SAAS,GAAAR,IAAA,CA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AAIiC,MAAM,EAAEhC,YAAY","ignoreList":[]}
@@ -25,7 +25,8 @@ function uuidv4() {
25
25
  var TripDetail = function TripDetail(_ref) {
26
26
  var icon = _ref.icon,
27
27
  summary = _ref.summary,
28
- description = _ref.description;
28
+ description = _ref.description,
29
+ className = _ref.className;
29
30
  var intl = useIntl();
30
31
  var _useState = useState(false),
31
32
  _useState2 = _slicedToArray(_useState, 2),
@@ -36,7 +37,8 @@ var TripDetail = function TripDetail(_ref) {
36
37
  setExpanded(!expanded);
37
38
  };
38
39
  return /*#__PURE__*/React.createElement(S.TripDetail, {
39
- role: "group"
40
+ role: "group",
41
+ className: className
40
42
  }, /*#__PURE__*/React.createElement(S.TripDetailIcon, {
41
43
  role: "presentation"
42
44
  }, icon), /*#__PURE__*/React.createElement(S.TripDetailSummary, null, summary, description && /*#__PURE__*/React.createElement(S.ExpandButton, {
@@ -1 +1 @@
1
- {"version":3,"file":"trip-detail.js","names":["React","useState","QuestionCircle","TimesCircle","AnimateHeight","useIntl","S","isRunningJest","process","env","JEST_WORKER_ID","undefined","uuidv4","replace","c","r","Math","random","v","toString","TripDetail","_ref","icon","summary","description","intl","_useState","_useState2","_slicedToArray","expanded","setExpanded","id","toggle","createElement","role","TripDetailIcon","TripDetailSummary","ExpandButton","formatMessage","onClick","tabIndex","size","duration","height","TripDetailDescription","HideButton"],"sources":["../src/trip-detail.tsx"],"sourcesContent":["import React, { ReactElement, useState } from \"react\";\nimport { QuestionCircle } from \"@styled-icons/fa-solid/QuestionCircle\";\nimport { TimesCircle } from \"@styled-icons/fa-solid/TimesCircle\";\n\nimport AnimateHeight from \"react-animate-height\";\nimport { useIntl } from \"react-intl\";\nimport * as S from \"./styled\";\n\ntype Props = {\n description?: ReactElement | string;\n icon: ReactElement;\n summary: ReactElement | string;\n};\n\n// TODO: Remove these two helper methods by moving to semantically correct HTML\n/**\n * Copied from https://stackoverflow.com/questions/50940640/how-to-determine-if-jest-is-running-the-code-or-not\n */\nfunction isRunningJest() {\n return process.env.JEST_WORKER_ID !== undefined;\n}\n\nfunction uuidv4(): string {\n if (isRunningJest()) return \"mocked-random-id\";\n\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, function(c) {\n // eslint-disable-next-line no-bitwise\n const r = (Math.random() * 16) | 0;\n // eslint-disable-next-line no-bitwise\n const v = c === \"x\" ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\nconst TripDetail = ({ icon, summary, description }: Props): JSX.Element => {\n const intl = useIntl();\n const [expanded, setExpanded] = useState(false);\n\n const id = uuidv4();\n\n const toggle = (): void => {\n setExpanded(!expanded);\n };\n\n return (\n <S.TripDetail role=\"group\">\n <S.TripDetailIcon role=\"presentation\">{icon}</S.TripDetailIcon>\n {/* TODO: Adjust the summary and description to be a `summary`/`details` pair, therefore semantically correct */}\n {/* https://github.com/opentripplanner/otp-ui/pull/530#discussion_r1074006057 */}\n <S.TripDetailSummary>\n {summary}\n {description && (\n <S.ExpandButton\n aria-label={\n expanded\n ? intl.formatMessage({\n id: \"otpUi.TripDetails.hideDetail\"\n })\n : intl.formatMessage({\n id: \"otpUi.TripDetails.showDetail\"\n })\n }\n aria-controls={id}\n aria-expanded={expanded}\n id=\"expand-button\"\n onClick={toggle}\n tabIndex={0}\n >\n <QuestionCircle size=\"0.92em\" />\n </S.ExpandButton>\n )}\n </S.TripDetailSummary>\n <AnimateHeight duration={300} height={expanded ? \"auto\" : 0}>\n <S.TripDetailDescription aria-labelledby=\"expand-button\" id={id}>\n {/** This button isn't needed for screen readers as the main expand-button is\n * more convenient.\n */}\n <S.HideButton role=\"presentation\" onClick={() => setExpanded(false)}>\n <TimesCircle size=\"0.92em\" />\n </S.HideButton>\n {description}\n </S.TripDetailDescription>\n </AnimateHeight>\n </S.TripDetail>\n );\n};\n\nexport default TripDetail;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAkBC,QAAQ,QAAQ,OAAO;AACrD,SAASC,cAAc,QAAQ,uCAA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
+ {"version":3,"file":"trip-detail.js","names":["React","useState","QuestionCircle","TimesCircle","AnimateHeight","useIntl","S","isRunningJest","process","env","JEST_WORKER_ID","undefined","uuidv4","replace","c","r","Math","random","v","toString","TripDetail","_ref","icon","summary","description","className","intl","_useState","_useState2","_slicedToArray","expanded","setExpanded","id","toggle","createElement","role","TripDetailIcon","TripDetailSummary","ExpandButton","formatMessage","onClick","tabIndex","size","duration","height","TripDetailDescription","HideButton"],"sources":["../src/trip-detail.tsx"],"sourcesContent":["import React, { ReactElement, useState } from \"react\";\nimport { QuestionCircle } from \"@styled-icons/fa-solid/QuestionCircle\";\nimport { TimesCircle } from \"@styled-icons/fa-solid/TimesCircle\";\n\nimport AnimateHeight from \"react-animate-height\";\nimport { useIntl } from \"react-intl\";\nimport * as S from \"./styled\";\n\ntype Props = {\n className?: string;\n description?: ReactElement | string;\n icon: ReactElement;\n summary: ReactElement | string;\n};\n\n// TODO: Remove these two helper methods by moving to semantically correct HTML\n/**\n * Copied from https://stackoverflow.com/questions/50940640/how-to-determine-if-jest-is-running-the-code-or-not\n */\nfunction isRunningJest() {\n return process.env.JEST_WORKER_ID !== undefined;\n}\n\nfunction uuidv4(): string {\n if (isRunningJest()) return \"mocked-random-id\";\n\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, function(c) {\n // eslint-disable-next-line no-bitwise\n const r = (Math.random() * 16) | 0;\n // eslint-disable-next-line no-bitwise\n const v = c === \"x\" ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\nconst TripDetail = ({\n icon,\n summary,\n description,\n className\n}: Props): JSX.Element => {\n const intl = useIntl();\n const [expanded, setExpanded] = useState(false);\n\n const id = uuidv4();\n\n const toggle = (): void => {\n setExpanded(!expanded);\n };\n\n return (\n <S.TripDetail role=\"group\" className={className}>\n <S.TripDetailIcon role=\"presentation\">{icon}</S.TripDetailIcon>\n {/* TODO: Adjust the summary and description to be a `summary`/`details` pair, therefore semantically correct */}\n {/* https://github.com/opentripplanner/otp-ui/pull/530#discussion_r1074006057 */}\n <S.TripDetailSummary>\n {summary}\n {description && (\n <S.ExpandButton\n aria-label={\n expanded\n ? intl.formatMessage({\n id: \"otpUi.TripDetails.hideDetail\"\n })\n : intl.formatMessage({\n id: \"otpUi.TripDetails.showDetail\"\n })\n }\n aria-controls={id}\n aria-expanded={expanded}\n id=\"expand-button\"\n onClick={toggle}\n tabIndex={0}\n >\n <QuestionCircle size=\"0.92em\" />\n </S.ExpandButton>\n )}\n </S.TripDetailSummary>\n <AnimateHeight duration={300} height={expanded ? \"auto\" : 0}>\n <S.TripDetailDescription aria-labelledby=\"expand-button\" id={id}>\n {/** This button isn't needed for screen readers as the main expand-button is\n * more convenient.\n */}\n <S.HideButton role=\"presentation\" onClick={() => setExpanded(false)}>\n <TimesCircle size=\"0.92em\" />\n </S.HideButton>\n {description}\n </S.TripDetailDescription>\n </AnimateHeight>\n </S.TripDetail>\n );\n};\n\nexport default TripDetail;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAkBC,QAAQ,QAAQ,OAAO;AACrD,SAASC,cAAc,QAAQ,uCAAuC;AACtE,SAASC,WAAW,QAAQ,oCAAoC;AAEhE,OAAOC,aAAa,MAAM,sBAAsB;AAChD,SAASC,OAAO,QAAQ,YAAY;AACpC,OAAO,KAAKC,CAAC,MAAM,UAAU;AAS7B;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAAA,EAAG;EACvB,OAAOC,OAAO,CAACC,GAAG,CAACC,cAAc,KAAKC,SAAS;AACjD;AAEA,SAASC,MAAMA,CAAA,EAAW;EACxB,IAAIL,aAAa,CAAC,CAAC,EAAE,OAAO,kBAAkB;EAE9C,OAAO,sCAAsC,CAACM,OAAO,CAAC,OAAO,EAAE,UAASC,CAAC,EAAE;IACzE;IACA,IAAMC,CAAC,GAAIC,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAI,CAAC;IAClC;IACA,IAAMC,CAAC,GAAGJ,C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AG;IAClB,iBAAeF,QAAS;IACxBE,EAAE,EAAC,eAAe;IAClBQ,OAAO,EAAEP,MAAO;IAChBQ,QAAQ,EAAE;EAAE,gBAEZzC,KAAA,CAAAkC,aAAA,CAAChC,cAAc;IAACwC,IAAI,EAAC;EAAQ,CAAE,CACjB,CAEC,CAAC,eACtB1C,KAAA,CAAAkC,aAAA,CAAC9B,aAAa;IAACuC,QAAQ,EAAE,GAAI;IAACC,MAAM,EAAEd,QAAQ,GAAG,MAAM,GAAG;EAAE,gBAC1D9B,KAAA,CAAAkC,aAAA,CAAC5B,CAAC,CAACuC,qBAAqB;IAAC,mBAAgB,eAAe;IAACb,EAAE,EAAEA;EAAG,gBAI9DhC,KAAA,CAAAkC,aAAA,CAAC5B,CAAC,CAACwC,UAAU;IAACX,IAAI,EAAC,cAAc;IAACK,OAAO,EAAE,SAATA,OAAOA,CAAA;MAAA,OAAQT,WAAW,CAAC,KAAK,CAAC;IAAA;EAAC,gBAClE/B,KAAA,CAAAkC,aAAA,CAAC/B,WAAW;IAACuC,IAAI,EAAC;EAAQ,CAAE,CAChB,CAAC,EACdlB,WACsB,CACZ,CACH,CAAC;AAEnB,CAAC;AAED,eAAeJ,UAAU","ignoreList":[]}
package/esm/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["// Prettier does not recognize the import type syntax.\n// eslint-disable-next-line prettier/prettier\nimport type { \n FareProductSelector, \n Itinerary, \n Leg, \n MassUnitOption,\n Money\n } from \"@opentripplanner/types\";\n\nexport interface TimeActiveDetailsProps {\n bikeMinutes: number;\n minutesActive?: number;\n walkMinutes: number;\n}\n\nexport interface CO2ConfigType {\n carbonIntensity?: Record<string, number>;\n units?: MassUnitOption;\n enabled?: boolean;\n}\n\nexport interface DepartureDetailsProps {\n departureDate: Date;\n}\n\n/**\n * This is the interface used to define the layout for a particular fare table.\n * The table with be rendered with the columns defined here,\n * with each row being an individual transit leg from the itinerary.\n */\nexport interface FareTableLayout {\n cols: (FareProductSelector & {\n columnHeaderKey: string;\n })[]\n headerKey: string;\n}\n/**\n * Interface containing the lgs and the layout of the fare table.\n */\nexport interface FareLegTableProps {\n layout?: FareTableLayout[];\n legs: Leg[];\n}\n\n// Total fare amount corresponding to a fare key\nexport type FareTotals = (FareProductSelector & { price: Money })[]\n\nexport interface FareDetailsProps {\n legs: Leg[];\n maxTNCFare: number;\n minTNCFare: number;\n}\n\n\nexport interface TripDetailsProps {\n /**\n * Used for additional styling with styled components for example.\n */\n className?: string;\n /**\n * Object containing the CO₂ config.\n */\n co2Config?: CO2ConfigType;\n /**\n * Determines which transit fare should be displayed by default, should there be multiple transit fare types.\n */\n defaultFareType?: { headerKey: string } & FareProductSelector;\n /**\n * Slot for a custom component to render the expandable section for departure.\n */\n DepartureDetails?: React.ElementType<DepartureDetailsProps>;\n /**\n * If this is set to true, a row will be added to the trip details displaying how\n * many minutes in total the user will spend walking or biking.\n */\n displayTimeActive?: boolean;\n /**\n * Slot for a custom component to render the expandable section for fares.\n */\n FareDetails?: React.ElementType<FareDetailsProps>;\n /**\n * Column and table configuration for fare details/fare by leg table.\n */\n fareDetailsLayout?: FareTableLayout[];\n /**\n * Mapping between fare keys and human-readable names for them.\n */\n fareKeyNameMap?: {\n [name: string]: string;\n };\n /**\n * Itinerary that the user has selected to view, contains multiple legs.\n */\n itinerary: Itinerary;\n /**\n * show the '~' symbol in the trip details panel\n */\n showApproximateMinutesActive?: boolean;\n /**\n * Slot for a custom component to render the expandable section for time active.\n */\n TimeActiveDetails?: React.ElementType<TimeActiveDetailsProps>;\n}"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["// Prettier does not recognize the import type syntax.\n// eslint-disable-next-line prettier/prettier\nimport type { \n FareProductSelector, \n Itinerary, \n Leg, \n MassUnitOption,\n Money\n } from \"@opentripplanner/types\";\n\nexport interface TimeActiveDetailsProps {\n bikeMinutes: number;\n minutesActive?: number;\n walkMinutes: number;\n}\n\nexport interface CO2ConfigType {\n carbonIntensity?: Record<string, number>;\n units?: MassUnitOption;\n enabled?: boolean;\n}\n\nexport interface DepartureDetailsProps {\n departureDate: Date;\n}\n\n/**\n * This is the interface used to define the layout for a particular fare table.\n * The table with be rendered with the columns defined here,\n * with each row being an individual transit leg from the itinerary.\n */\nexport interface FareTableLayout {\n cols: (FareProductSelector & {\n columnHeaderKey: string;\n })[]\n headerKey: string;\n}\n/**\n * Interface containing the lgs and the layout of the fare table.\n */\nexport interface FareLegTableProps {\n layout?: FareTableLayout[];\n legs: Leg[];\n}\n\n// Total fare amount corresponding to a fare key\nexport type FareTotals = (FareProductSelector & { price: Money })[]\n\nexport interface FareDetailsProps {\n legs: Leg[];\n maxTNCFare: number;\n minTNCFare: number;\n}\n\nexport interface FareConfig {\n /**\n * Determines which transit fare should be displayed by default, should there be multiple transit fare types.\n */\n defaultFareType?: { headerKey: string } & FareProductSelector;\n /**\n * Column and table configuration for fare details/fare by leg table.\n */\n fareDetailsLayout?: FareTableLayout[];\n /**\n * Mapping between fare keys and human-readable names for them.\n */\n fareKeyNameMap?: {\n [name: string]: string;\n };\n}\n\nexport interface TripDetailsProps {\n /**\n * Used for additional styling with styled components for example.\n */\n className?: string;\n /**\n * Object containing the CO₂ config.\n */\n co2Config?: CO2ConfigType;\n /**\n * Slot for a custom component to render the expandable section for departure.\n */\n DepartureDetails?: React.ElementType<DepartureDetailsProps>;\n /**\n * Slot for a custom component to render the expandable section for fares.\n */\n FareDetails?: React.ElementType<FareDetailsProps>;\n /**\n * Configuration for fare details/fare by leg table.\n */\n fareConfig?: FareConfig;\n /**\n * Itinerary that the user has selected to view, contains multiple legs.\n */\n itinerary: Itinerary;\n /**\n * show the '~' symbol in the trip details panel\n */\n showApproximateMinutesActive?: boolean;\n /**\n * Slot for a custom component to render the expandable section for time active.\n */\n TimeActiveDetails?: React.ElementType<TimeActiveDetailsProps>;\n}"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import { Itinerary } from "@opentripplanner/types";
2
+ import React, { ReactElement } from "react";
3
+ import { DepartureDetailsProps } from "../types";
4
+ interface DepartureDateProps {
5
+ itinerary: Itinerary;
6
+ DepartureDetails?: React.ElementType<DepartureDetailsProps>;
7
+ }
8
+ export default function DepartureDate({ itinerary, DepartureDetails }: DepartureDateProps): ReactElement;
9
+ export {};
10
+ //# sourceMappingURL=departure-date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"departure-date.d.ts","sourceRoot":"","sources":["../../src/components/departure-date.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAK5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAajD,UAAU,kBAAkB;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,gBAAgB,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;CAC7D;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,SAAS,EACT,gBAAgB,EACjB,EAAE,kBAAkB,GAAG,YAAY,CAyBnC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = DepartureDate;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactIntl = require("react-intl");
10
+ var _CalendarAlt = require("@styled-icons/fa-solid/CalendarAlt");
11
+ var _flat = _interopRequireDefault(require("flat"));
12
+ var _utils = require("../utils");
13
+ var _tripDetail = _interopRequireDefault(require("../trip-detail"));
14
+ var S = _interopRequireWildcard(require("../styled"));
15
+ var _enUS = _interopRequireDefault(require("../../i18n/en-US.yml"));
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ // Load the default messages.
19
+
20
+ // HACK: We should flatten the messages loaded above because
21
+ // the YAML loaders behave differently between webpack and our version of jest:
22
+ // - the yaml loader for webpack returns a nested object,
23
+ // - the yaml loader for jest returns messages with flattened ids.
24
+ const defaultMessages = (0, _flat.default)(_enUS.default);
25
+ function DepartureDate({
26
+ itinerary,
27
+ DepartureDetails
28
+ }) {
29
+ const departureDate = new Date(itinerary.startTime);
30
+ return /*#__PURE__*/_react.default.createElement(_tripDetail.default, {
31
+ className: "departure-date"
32
+ // Any custom description for the Departure message needs to be handled by the slot.
33
+ ,
34
+ description: DepartureDetails && /*#__PURE__*/_react.default.createElement(DepartureDetails, {
35
+ departureDate: departureDate
36
+ }),
37
+ icon: /*#__PURE__*/_react.default.createElement(_CalendarAlt.CalendarAlt, {
38
+ size: 17
39
+ }),
40
+ summary: /*#__PURE__*/_react.default.createElement(S.Timing, null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
41
+ defaultMessage: defaultMessages["otpUi.TripDetails.departure"],
42
+ description: "Text showing the departure date/time for a trip.",
43
+ id: "otpUi.TripDetails.departure",
44
+ values: {
45
+ departureDate,
46
+ strong: _utils.boldText
47
+ }
48
+ }))
49
+ });
50
+ }
51
+ //# sourceMappingURL=departure-date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"departure-date.js","names":["_react","_interopRequireDefault","require","_reactIntl","_CalendarAlt","_flat","_utils","_tripDetail","S","_interopRequireWildcard","_enUS","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","defaultMessages","flatten","defaultEnglishMessages","DepartureDate","itinerary","DepartureDetails","departureDate","Date","startTime","createElement","className","description","icon","CalendarAlt","size","summary","Timing","FormattedMessage","defaultMessage","id","values","strong","boldText"],"sources":["../../src/components/departure-date.tsx"],"sourcesContent":["import { Itinerary } from \"@opentripplanner/types\";\nimport React, { ReactElement } from \"react\";\nimport { FormattedMessage } from \"react-intl\";\nimport { CalendarAlt } from \"@styled-icons/fa-solid/CalendarAlt\";\nimport flatten from \"flat\";\nimport { boldText } from \"../utils\";\nimport { DepartureDetailsProps } from \"../types\";\nimport TripDetail from \"../trip-detail\";\nimport * as S from \"../styled\";\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\ninterface DepartureDateProps {\n itinerary: Itinerary;\n DepartureDetails?: React.ElementType<DepartureDetailsProps>;\n}\n\nexport default function DepartureDate({\n itinerary,\n DepartureDetails\n}: DepartureDateProps): ReactElement {\n const departureDate = new Date(itinerary.startTime);\n return (\n <TripDetail\n className=\"departure-date\"\n // Any custom description for the Departure message needs to be handled by the slot.\n description={\n DepartureDetails && <DepartureDetails departureDate={departureDate} />\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 }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,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAD1D;;AAGA;AACA;AACA;AACA;AACA,MAAMW,eAAuC,GAAG,IAAAC,aAAO,EAACC,aAAsB,CAAC;AAOhE,SAASC,aAAaA,CAAC;EACpCC,SAAS;EACTC;AACkB,CAAC,EAAgB;EACnC,MAAMC,aAAa,GAAG,IAAIC,IAAI,CAACH,SAAS,CAACI,SAAS,CAAC;EACnD,oBACEvC,MAAA,CAAAiB,OAAA,CAAAuB,aAAA,CAACjC,WAAA,CAAAU,OAAU;IACTwB,SAAS,EAAC;IACV;IAAA;IACAC,WAAW,EACTN,gBAAgB,iBAAIpC,MAAA,CAAAiB,OAAA,CAAAuB,aAAA,CAACJ,gBAAgB;MAACC,aAAa,EAAEA;IAAc,CAAE,CACtE;IACDM,IAAI,eAAE3C,MAAA,CAAAiB,OAAA,CAAAuB,aAAA,CAACpC,YAAA,CAAAwC,WAAW;MAACC,IAAI,EAAE;IAAG,CAAE,CAAE;IAChCC,OAAO,eACL9C,MAAA,CAAAiB,OAAA,CAAAuB,aAAA,CAAChC,CAAC,CAACuC,MAAM,qBACP/C,MAAA,CAAAiB,OAAA,CAAAuB,aAAA,CAACrC,UAAA,CAAA6C,gBAAgB;MACfC,cAAc,EAAElB,eAAe,CAAC,6BAA6B,CAAE;MAC/DW,WAAW,EAAC,kDAAkD;MAC9DQ,EAAE,EAAC,6BAA6B;MAChCC,MAAM,EAAE;QACNd,aAAa;QACbe,MAAM,EAAEC;MACV;IAAE,CACH,CACO;EACX,CACF,CAAC;AAEN","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { Itinerary } from "@opentripplanner/types";
3
+ import { CO2ConfigType } from "../types";
4
+ export default function Emissions({ itinerary, co2Config }: {
5
+ itinerary: Itinerary;
6
+ co2Config: CO2ConfigType;
7
+ }): JSX.Element | null;
8
+ //# sourceMappingURL=emissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emissions.d.ts","sourceRoot":"","sources":["../../src/components/emissions.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAMnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAwBzC,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,SAAS,EACT,SAAS,EACV,EAAE;IACD,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,aAAa,CAAC;CAC1B,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CA0DrB"}