@opentripplanner/trip-details 8.0.2 → 9.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 (78) hide show
  1. package/esm/components/fares-v2-table.js +194 -0
  2. package/esm/components/fares-v2-table.js.map +1 -0
  3. package/esm/components/fares.js +28 -58
  4. package/esm/components/fares.js.map +1 -1
  5. package/esm/index.js +5 -5
  6. package/esm/index.js.map +1 -1
  7. package/esm/styled.js +29 -22
  8. package/esm/styled.js.map +1 -1
  9. package/esm/trip-detail.js +1 -8
  10. package/esm/trip-detail.js.map +1 -1
  11. package/esm/types.js.map +1 -1
  12. package/i18n/en-US.yml +2 -7
  13. package/i18n/es.yml +0 -7
  14. package/i18n/fr.yml +2 -7
  15. package/i18n/ko.yml +2 -9
  16. package/i18n/nb_NO.yml +1 -4
  17. package/i18n/pl.yml +24 -19
  18. package/i18n/ru.yml +3 -10
  19. package/i18n/ta.yml +20 -25
  20. package/i18n/tl.yml +2 -9
  21. package/i18n/tr.yml +0 -7
  22. package/i18n/vi.yml +2 -9
  23. package/i18n/zh_Hans.yml +2 -9
  24. package/i18n/zh_Hant.yml +0 -7
  25. package/lib/components/departure-date.js +45 -42
  26. package/lib/components/departure-date.js.map +1 -1
  27. package/lib/components/emissions.js +57 -64
  28. package/lib/components/emissions.js.map +1 -1
  29. package/lib/components/fares-v2-table.d.ts +9 -0
  30. package/lib/components/fares-v2-table.d.ts.map +1 -0
  31. package/lib/components/fares-v2-table.js +158 -0
  32. package/lib/components/fares-v2-table.js.map +1 -0
  33. package/lib/components/fares.d.ts +4 -4
  34. package/lib/components/fares.d.ts.map +1 -1
  35. package/lib/components/fares.js +87 -151
  36. package/lib/components/fares.js.map +1 -1
  37. package/lib/components/flex-booking-info.js +55 -38
  38. package/lib/components/flex-booking-info.js.map +1 -1
  39. package/lib/components/time-active.js +40 -66
  40. package/lib/components/time-active.js.map +1 -1
  41. package/lib/index.d.ts +3 -3
  42. package/lib/index.d.ts.map +1 -1
  43. package/lib/index.js +53 -66
  44. package/lib/index.js.map +1 -1
  45. package/lib/styled.d.ts +1 -0
  46. package/lib/styled.d.ts.map +1 -1
  47. package/lib/styled.js +120 -86
  48. package/lib/styled.js.map +1 -1
  49. package/lib/trip-detail.d.ts.map +1 -1
  50. package/lib/trip-detail.js +65 -71
  51. package/lib/trip-detail.js.map +1 -1
  52. package/lib/types.d.ts +4 -41
  53. package/lib/types.d.ts.map +1 -1
  54. package/lib/types.js +1 -4
  55. package/lib/types.js.map +1 -1
  56. package/lib/utils.js +17 -23
  57. package/lib/utils.js.map +1 -1
  58. package/package.json +3 -5
  59. package/src/TripDetails.story.tsx +47 -158
  60. package/src/__snapshots__/TripDetails.story.tsx.snap +1726 -924
  61. package/src/components/fares-v2-table.tsx +262 -0
  62. package/src/components/fares.tsx +48 -87
  63. package/src/index.tsx +4 -4
  64. package/src/styled.ts +11 -2
  65. package/src/trip-detail.tsx +1 -10
  66. package/src/types.ts +4 -40
  67. package/tsconfig.json +1 -1
  68. package/tsconfig.tsbuildinfo +1 -1
  69. package/__mocks__/custom-english-messages.yml +0 -14
  70. package/__mocks__/custom-french-messages.yml +0 -9
  71. package/esm/components/fare-table.js +0 -122
  72. package/esm/components/fare-table.js.map +0 -1
  73. package/i18n/i18n-exceptions.json +0 -12
  74. package/lib/components/fare-table.d.ts +0 -5
  75. package/lib/components/fare-table.d.ts.map +0 -1
  76. package/lib/components/fare-table.js +0 -118
  77. package/lib/components/fare-table.js.map +0 -1
  78. package/src/components/fare-table.tsx +0 -215
@@ -0,0 +1,262 @@
1
+ /* eslint-disable no-underscore-dangle */
2
+ import React from "react";
3
+ import { Leg } from "@opentripplanner/types";
4
+ import coreUtils from "@opentripplanner/core-utils";
5
+ import { FormattedMessage, useIntl } from "react-intl";
6
+ import styled from "styled-components";
7
+ import { Transfer } from "@styled-icons/boxicons-regular/Transfer";
8
+
9
+ import { renderFare } from "../utils";
10
+ import { InvisibleA11yCaption, InvisibleA11yLabel } from "../styled";
11
+
12
+ // TODO: inline this import? (@opentripplanner/core-utils/src/itinerary)
13
+ const {
14
+ getLegCost,
15
+ getItineraryCost,
16
+ descope,
17
+ getLegRouteName
18
+ } = coreUtils.itinerary;
19
+
20
+ const FailDash = (
21
+ <>
22
+ -
23
+ <InvisibleA11yLabel>
24
+ <FormattedMessage id="otpUi.TripDetails.legMissingFareInfo" />
25
+ </InvisibleA11yLabel>
26
+ </>
27
+ );
28
+
29
+ const TransferIcon = styled(Transfer)`
30
+ padding-right: 0.25ch;
31
+ `;
32
+
33
+ const StripedTable = styled.table`
34
+ text-align: right;
35
+
36
+ tr td,
37
+ tr th {
38
+ padding: 4px;
39
+ }
40
+
41
+ tr td:nth-of-type(2n + 1),
42
+ tr th:nth-of-type(2n) {
43
+ background: #cccccc55;
44
+ border-color: #cccccc55;
45
+ }
46
+ `;
47
+
48
+ type IdNamePair = { id: string; name: string };
49
+
50
+ // Removes duplicates
51
+ const categoryReducer = (acc: IdNamePair[], cur: IdNamePair) => {
52
+ if (!acc.some(m => descope(m?.id) === descope(cur?.id))) {
53
+ acc.push(cur);
54
+ }
55
+ return acc;
56
+ };
57
+
58
+ // Put the preferred medium first, and then all the others alphabetical
59
+ const categorySorter = (favoriteId?: string) => (
60
+ a: IdNamePair,
61
+ b: IdNamePair
62
+ ): number => {
63
+ const aId = descope(a?.id);
64
+ const bId = descope(b?.id);
65
+
66
+ if (favoriteId && aId === favoriteId) {
67
+ return -1;
68
+ }
69
+ if (favoriteId && bId === favoriteId) {
70
+ return 1;
71
+ }
72
+
73
+ return aId > bId ? 1 : -1;
74
+ };
75
+
76
+ // TODO: This component currently can only show one type of fare per medium
77
+ const FaresV2Table = ({
78
+ legs,
79
+ favoriteMediumId,
80
+ favoriteRiderCategoryId
81
+ }: {
82
+ legs: Leg[];
83
+ favoriteMediumId?: string;
84
+ favoriteRiderCategoryId?: string;
85
+ }): JSX.Element => {
86
+ const intl = useIntl();
87
+
88
+ const transitLegs = legs.filter(leg => leg.transitLeg);
89
+
90
+ // Get all fare products across all legs
91
+ const fareProducts = transitLegs.flatMap(leg => leg.fareProducts);
92
+
93
+ // Reduce these into mediums and riders
94
+ const mediums = fareProducts
95
+ .map(fp => fp.product?.medium)
96
+ .filter(m => m !== null)
97
+ .reduce(categoryReducer, [])
98
+ .sort(categorySorter(favoriteMediumId));
99
+ const riders = fareProducts
100
+ .map(fp => fp.product?.riderCategory)
101
+ .filter(r => r !== null)
102
+ .reduce(categoryReducer, [])
103
+ .sort(categorySorter(favoriteRiderCategoryId));
104
+
105
+ // Ensure we have at least one rider/medium
106
+ if (riders.length === 0) {
107
+ riders.push({ name: "Fare", id: null });
108
+ }
109
+ if (mediums.length === 0) {
110
+ mediums.push({ name: "Regular", id: null });
111
+ }
112
+
113
+ // Keep track of seen fare ids to indicate transfers
114
+ const productUseIds: Set<string> = new Set();
115
+
116
+ const rows = [
117
+ [
118
+ <th key="faretitle" style={{ textAlign: "left" }}>
119
+ <InvisibleA11yLabel>
120
+ <FormattedMessage id="otpUi.TripDetails.transitFare" />
121
+ </InvisibleA11yLabel>
122
+ </th>,
123
+ ...transitLegs.map(leg => (
124
+ <th key={leg.tripId}>{getLegRouteName(leg)}</th>
125
+ )),
126
+ transitLegs.length > 1 ? (
127
+ <th key="total" style={{ textAlign: "right" }}>
128
+ <em>
129
+ <FormattedMessage id="otpUi.TripDetails.total" />
130
+ </em>
131
+ </th>
132
+ ) : (
133
+ <></>
134
+ )
135
+ ]
136
+ ];
137
+
138
+ // non-transit legs don't have fares
139
+ transitLegs.forEach((leg, index) => {
140
+ mediums.forEach((medium, mediumIndex) => {
141
+ riders.forEach((rider, riderIndex) => {
142
+ if (!medium || !rider) return;
143
+ const {
144
+ alternateFareProducts,
145
+ isDependent,
146
+ appliedFareProduct,
147
+ productUseId
148
+ } = getLegCost(
149
+ leg,
150
+ descope(medium.id) || null,
151
+ descope(rider.id) || null,
152
+ Array.from(productUseIds)
153
+ );
154
+ const legPrice = appliedFareProduct?.legPrice;
155
+
156
+ productUseIds.add(productUseId);
157
+
158
+ // Only consider alternateFareProducts if current product is dependent
159
+ const dependentAlternateFareProducts =
160
+ isDependent && alternateFareProducts;
161
+
162
+ // Calculate pre-tranfer amount either via alternate fare or fare-id matching (price.originalAmount)
163
+ const originalAmount =
164
+ dependentAlternateFareProducts?.[0]?.price.amount -
165
+ legPrice?.amount ||
166
+ appliedFareProduct?.price.amount - legPrice?.amount;
167
+
168
+ const newCell = (
169
+ <>
170
+ {/* Only render the list of fare types once */}
171
+ {index === 0 && (
172
+ <th style={{ textAlign: "left" }}>
173
+ <FormattedMessage
174
+ id={`config.fares.media.${descope(medium.id)}`}
175
+ defaultMessage={medium.name}
176
+ />{" "}
177
+ <FormattedMessage
178
+ id={`config.fares.riderCategory.${descope(rider.id)}`}
179
+ defaultMessage={rider.name}
180
+ />
181
+ </th>
182
+ )}
183
+ <td
184
+ style={{ textAlign: legPrice ? "right" : "center" }}
185
+ title={
186
+ !Number.isNaN(originalAmount) &&
187
+ originalAmount > 0 &&
188
+ index > 0 &&
189
+ intl.formatMessage(
190
+ {
191
+ description:
192
+ "Text explaining the transfer discount applied to this fare.",
193
+ id: "otpUi.TripDetails.transferDiscountExplanation"
194
+ },
195
+ {
196
+ transferAmount: intl.formatNumber(originalAmount, {
197
+ currency: legPrice?.currency?.code,
198
+ currencyDisplay: "narrowSymbol",
199
+ style: "currency"
200
+ })
201
+ }
202
+ )
203
+ }
204
+ >
205
+ {!Number.isNaN(originalAmount) &&
206
+ originalAmount > 0 &&
207
+ index > 0 && <TransferIcon size={16} />}
208
+ {/* Leg Price will always be defined if the fare product has a price */}
209
+ {legPrice
210
+ ? renderFare(legPrice?.currency?.code, legPrice?.amount)
211
+ : FailDash}
212
+ </td>
213
+ </>
214
+ );
215
+ const currentRowIndex = 1 + riderIndex + riders.length * mediumIndex;
216
+ if (!rows[currentRowIndex]) {
217
+ rows[currentRowIndex] = [];
218
+ }
219
+ rows[currentRowIndex].push(newCell);
220
+
221
+ // Generate final column
222
+ if (index === transitLegs.length - 1 && transitLegs.length > 1) {
223
+ const fare = getItineraryCost(
224
+ legs,
225
+ descope(medium.id) || null,
226
+ descope(rider.id) || null
227
+ );
228
+ rows[currentRowIndex].push(
229
+ <td
230
+ style={{ textAlign: fare?.amount ? "right" : "center" }}
231
+ title={
232
+ !fare?.amount &&
233
+ intl.formatMessage({
234
+ id: "otpUi.TripDetails.missingFareTotal"
235
+ })
236
+ }
237
+ >
238
+ <em>
239
+ {fare?.amount
240
+ ? renderFare(fare?.currency.code, fare?.amount)
241
+ : FailDash}
242
+ </em>
243
+ </td>
244
+ );
245
+ }
246
+ });
247
+ });
248
+ });
249
+
250
+ return (
251
+ <StripedTable>
252
+ <InvisibleA11yCaption>
253
+ <FormattedMessage id="otpUi.TripDetails.transitFareTable" />
254
+ </InvisibleA11yCaption>
255
+ {rows.map((r, index) => (
256
+ <tr key={index}>{r}</tr>
257
+ ))}
258
+ </StripedTable>
259
+ );
260
+ };
261
+
262
+ export default FaresV2Table;
@@ -1,40 +1,39 @@
1
1
  import React, { ReactElement } from "react";
2
2
  import { FormattedMessage } from "react-intl";
3
- import flatten from "flat";
4
3
  import coreUtils from "@opentripplanner/core-utils";
5
4
  import { FareProductSelector, Itinerary } from "@opentripplanner/types";
6
5
  import { MoneyBillAlt } from "@styled-icons/fa-solid";
6
+ import { flatten } from "flat";
7
7
  import * as S from "../styled";
8
8
  import { boldText, renderFare } from "../utils";
9
9
  import TripDetail from "../trip-detail";
10
- import { FareConfig, FareDetailsProps } from "../types";
11
- import FareLegTable from "./fare-table";
10
+ import { FareDetailsProps } from "../types";
11
+ import FaresV2Table from "./fares-v2-table";
12
12
 
13
13
  // Load the default messages.
14
14
  import defaultEnglishMessages from "../../i18n/en-US.yml";
15
15
 
16
+ export interface FaresProps {
17
+ itinerary: Itinerary;
18
+ FareDetails?: React.ElementType<FareDetailsProps>;
19
+ defaultFareType?: FareProductSelector;
20
+ }
21
+
16
22
  // HACK: We should flatten the messages loaded above because
17
23
  // the YAML loaders behave differently between webpack and our version of jest:
18
24
  // - the yaml loader for webpack returns a nested object,
19
25
  // - the yaml loader for jest returns messages with flattened ids.
20
26
  const defaultMessages: Record<string, string> = flatten(defaultEnglishMessages);
21
27
 
22
- export interface FaresProps {
23
- itinerary: Itinerary;
24
- FareDetails?: React.ElementType<FareDetailsProps>;
25
- fareConfig?: FareConfig;
26
- }
27
-
28
28
  export default function Fares({
29
29
  itinerary,
30
30
  FareDetails,
31
- fareConfig = {}
31
+ defaultFareType
32
32
  }: FaresProps): ReactElement | null {
33
+ // process the transit fare
33
34
  const fareResult = coreUtils.itinerary.calculateTncFares(itinerary);
34
35
  const { currencyCode, maxTNCFare, minTNCFare } = fareResult;
35
36
 
36
- const { defaultFareType, fareDetailsLayout, fareKeyNameMap } = fareConfig;
37
-
38
37
  const { companies, fareTypes } = itinerary.legs.reduce<{
39
38
  companies: string;
40
39
  fareTypes: FareProductSelector[];
@@ -64,86 +63,48 @@ export default function Fares({
64
63
  { companies: "", fareTypes: [] }
65
64
  );
66
65
 
67
- let fare;
68
- if (fareTypes.length > 0 && defaultFareType) {
69
- const defaultFareTotal = coreUtils.itinerary.getItineraryCost(
70
- itinerary.legs,
71
- defaultFareType.mediumId,
72
- defaultFareType.riderCategoryId
73
- );
74
- // Depending on if there are additional fares to display either render a <span> or a <details>
75
- const TransitFareWrapper =
76
- fareTypes.length > 1 ? S.TransitFare : S.TransitFareSingle;
77
-
78
- const fareNameFallback = (
79
- <FormattedMessage
80
- defaultMessage={defaultMessages["otpUi.TripDetails.transitFare"]}
81
- description="Text showing the price of tickets on public transportation."
82
- id="otpUi.TripDetails.transitFare"
83
- />
84
- );
85
-
86
- fare = defaultFareTotal !== undefined && (
87
- <S.Fare>
88
- <TransitFareWrapper>
89
- <summary style={{ display: fareTypes.length > 1 ? "list-item" : "" }}>
90
- <FormattedMessage
91
- defaultMessage={
92
- defaultMessages["otpUi.TripDetails.transitFareEntry"]
93
- }
94
- description="Text showing the price of tickets on public transportation."
95
- id="otpUi.TripDetails.transitFareEntry"
96
- values={{
97
- name:
98
- (defaultFareType.headerKey &&
99
- fareKeyNameMap?.[defaultFareType.headerKey]) ||
100
- fareNameFallback,
101
- strong: boldText,
102
- value: renderFare(
103
- defaultFareTotal.currency?.code || "USD",
104
- defaultFareTotal?.amount
105
- )
106
- }}
107
- />
108
- </summary>
109
- {fareDetailsLayout ? (
110
- // Show full ƒare details by leg
111
- <FareLegTable layout={fareDetailsLayout} legs={itinerary.legs} />
112
- ) : (
113
- // Just show the fares for each payment type
114
- fareTypes.map(fareType => {
115
- // Don't show the default fare twice!
116
- if (fareType) {
117
- return null;
118
- }
119
- return (
66
+ const defaultFareTotal = coreUtils.itinerary.getItineraryCost(
67
+ itinerary.legs,
68
+ defaultFareType?.mediumId || null,
69
+ defaultFareType?.riderCategoryId || null
70
+ );
71
+ // Depending on if there are additional fares to display either render a <span> or a <details>
72
+ const fare = defaultFareTotal !== undefined && (
73
+ <S.Fare>
74
+ <S.TransitFare>
75
+ <summary style={{ display: fareTypes.length > 1 ? "list-item" : "" }}>
76
+ <FormattedMessage
77
+ defaultMessage={
78
+ defaultMessages["otpUi.TripDetails.transitFareEntry"]
79
+ }
80
+ description="Text showing the price of tickets on public transportation."
81
+ id="otpUi.TripDetails.transitFareEntry"
82
+ values={{
83
+ name: (
120
84
  <FormattedMessage
121
85
  defaultMessage={
122
- defaultMessages["otpUi.TripDetails.transitFareEntry"]
86
+ defaultMessages["otpUi.TripDetails.transitFare"]
123
87
  }
124
88
  description="Text showing the price of tickets on public transportation."
125
- id="otpUi.TripDetails.transitFareEntry"
126
- key={Object.values(fareType).join("-")}
127
- values={{
128
- name:
129
- (defaultFareType.headerKey &&
130
- fareKeyNameMap?.[defaultFareType.headerKey]) ||
131
- fareNameFallback,
132
- strong: boldText,
133
- value: renderFare(
134
- defaultFareTotal.currency?.code || "USD",
135
- defaultFareTotal?.amount /
136
- defaultFareTotal?.currency?.digits
137
- )
138
- }}
89
+ id="otpUi.TripDetails.transitFare"
139
90
  />
140
- );
141
- })
142
- )}
143
- </TransitFareWrapper>
144
- </S.Fare>
145
- );
146
- }
91
+ ),
92
+ strong: boldText,
93
+ value: renderFare(
94
+ defaultFareTotal.currency?.code || "USD",
95
+ defaultFareTotal?.amount
96
+ )
97
+ }}
98
+ />
99
+ </summary>
100
+ <FaresV2Table
101
+ legs={itinerary.legs}
102
+ favoriteMediumId={defaultFareType?.mediumId}
103
+ favoriteRiderCategoryId={defaultFareType?.riderCategoryId}
104
+ />
105
+ </S.TransitFare>
106
+ </S.Fare>
107
+ );
147
108
  const tncFare = minTNCFare !== 0 && (
148
109
  <S.Fare>
149
110
  <S.TNCFare>
package/src/index.tsx CHANGED
@@ -2,9 +2,9 @@ import React, { ReactElement } from "react";
2
2
  import { FormattedMessage } from "react-intl";
3
3
  import { flatten } from "flat";
4
4
  import * as S from "./styled";
5
- import FareLegTable from "./components/fare-table";
6
5
  import { TripDetailsProps } from "./types";
7
6
  import FlexBookingInfo from "./components/flex-booking-info";
7
+ import FaresV2Table from "./components/fares-v2-table";
8
8
  import Emissions from "./components/emissions";
9
9
  import Fares from "./components/fares";
10
10
  import TimeActive, { DefaultTimeActiveDetails } from "./components/time-active";
@@ -29,9 +29,9 @@ function cn(className: string, arg1: string): string {
29
29
  export function TripDetails({
30
30
  className = "",
31
31
  co2Config,
32
+ defaultFareType,
32
33
  DepartureDetails = null,
33
34
  FareDetails = null,
34
- fareConfig,
35
35
  itinerary,
36
36
  showApproximateMinutesActive,
37
37
  TimeActiveDetails = DefaultTimeActiveDetails
@@ -54,8 +54,8 @@ export function TripDetails({
54
54
  />
55
55
  <Fares
56
56
  itinerary={itinerary}
57
- fareConfig={fareConfig}
58
57
  FareDetails={FareDetails}
58
+ defaultFareType={defaultFareType}
59
59
  />
60
60
  <TimeActive
61
61
  itinerary={itinerary}
@@ -72,4 +72,4 @@ export function TripDetails({
72
72
  export default TripDetails;
73
73
 
74
74
  // Rename styled components for export.
75
- export { S as Styled, FareLegTable };
75
+ export { S as Styled, FaresV2Table };
package/src/styled.ts CHANGED
@@ -1,6 +1,6 @@
1
- import styled from "styled-components";
1
+ import styled, { css } from "styled-components";
2
2
 
3
- export const InvisibleA11yLabel = styled.span`
3
+ const InvisibleA11yStyles = css`
4
4
  display: inline-block;
5
5
  clip: rect(0, 0, 0, 0);
6
6
  height: 0;
@@ -8,6 +8,14 @@ export const InvisibleA11yLabel = styled.span`
8
8
  position: absolute;
9
9
  width: 0;
10
10
  `;
11
+ export const InvisibleA11yLabel = styled.span`
12
+ ${InvisibleA11yStyles}
13
+ `;
14
+
15
+ // Warning: https://github.com/opentripplanner/otp-ui/pull/855#discussion_r2248534209
16
+ export const InvisibleA11yCaption = styled.caption`
17
+ ${InvisibleA11yStyles}
18
+ `;
11
19
 
12
20
  const BaseButton = styled.button`
13
21
  background: transparent;
@@ -88,6 +96,7 @@ export const TripDetails = styled.div`
88
96
  margin-bottom: 15px;
89
97
  margin-top: 16px;
90
98
  padding: 10px 16px;
99
+ overflow-x: scroll;
91
100
  `;
92
101
 
93
102
  export const TripDetailsBody = styled.div``;
@@ -13,17 +13,8 @@ type Props = {
13
13
  summary: ReactElement | string;
14
14
  };
15
15
 
16
- // TODO: Remove these two helper methods by moving to semantically correct HTML
17
- /**
18
- * Copied from https://stackoverflow.com/questions/50940640/how-to-determine-if-jest-is-running-the-code-or-not
19
- */
20
- function isRunningJest() {
21
- return process.env.JEST_WORKER_ID !== undefined;
22
- }
23
-
16
+ // TODO: Remove this helper method by moving to semantically correct HTML
24
17
  function uuidv4(): string {
25
- if (isRunningJest()) return "mocked-random-id";
26
-
27
18
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
28
19
  // eslint-disable-next-line no-bitwise
29
20
  const r = (Math.random() * 16) | 0;
package/src/types.ts CHANGED
@@ -24,24 +24,6 @@ export interface DepartureDetailsProps {
24
24
  departureDate: Date;
25
25
  }
26
26
 
27
- /**
28
- * This is the interface used to define the layout for a particular fare table.
29
- * The table with be rendered with the columns defined here,
30
- * with each row being an individual transit leg from the itinerary.
31
- */
32
- export interface FareTableLayout {
33
- cols: (FareProductSelector & {
34
- columnHeaderKey: string;
35
- })[]
36
- headerKey: string;
37
- }
38
- /**
39
- * Interface containing the lgs and the layout of the fare table.
40
- */
41
- export interface FareLegTableProps {
42
- layout?: FareTableLayout[];
43
- legs: Leg[];
44
- }
45
27
 
46
28
  // Total fare amount corresponding to a fare key
47
29
  export type FareTotals = (FareProductSelector & { price: Money })[]
@@ -52,24 +34,6 @@ export interface FareDetailsProps {
52
34
  minTNCFare: number;
53
35
  }
54
36
 
55
- export interface FareConfig {
56
- /**
57
- * Determines which transit fare should be displayed by default, should there be multiple transit fare types.
58
- * Header key is used only in the old fare display.
59
- */
60
- defaultFareType?: { headerKey?: string } & FareProductSelector;
61
- /**
62
- * Column and table configuration for fare details/fare by leg table.
63
- */
64
- fareDetailsLayout?: FareTableLayout[];
65
- /**
66
- * Mapping between fare keys and human-readable names for them.
67
- */
68
- fareKeyNameMap?: {
69
- [name: string]: string;
70
- };
71
- }
72
-
73
37
  export interface TripDetailsProps {
74
38
  /**
75
39
  * Used for additional styling with styled components for example.
@@ -79,6 +43,10 @@ export interface TripDetailsProps {
79
43
  * Object containing the CO₂ config.
80
44
  */
81
45
  co2Config?: CO2ConfigType;
46
+ /**
47
+ * Determines which transit fare should be displayed by default, should there be multiple transit fare types.
48
+ */
49
+ defaultFareType?: FareProductSelector;
82
50
  /**
83
51
  * Slot for a custom component to render the expandable section for departure.
84
52
  */
@@ -87,10 +55,6 @@ export interface TripDetailsProps {
87
55
  * Slot for a custom component to render the expandable section for fares.
88
56
  */
89
57
  FareDetails?: React.ElementType<FareDetailsProps>;
90
- /**
91
- * Configuration for fare details/fare by leg table.
92
- */
93
- fareConfig?: FareConfig;
94
58
  /**
95
59
  * Itinerary that the user has selected to view, contains multiple legs.
96
60
  */
package/tsconfig.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "composite": true,
5
5
  "outDir": "./lib",
6
6
  "rootDir": "./src",
7
- "target": "ES2015",
7
+ "target": "ES2019",
8
8
  "skipLibCheck": true
9
9
  },
10
10
  "include": ["src/**/*"],