@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.
- package/esm/components/departure-date.js +42 -0
- package/esm/components/departure-date.js.map +1 -0
- package/esm/components/emissions.js +68 -0
- package/esm/components/emissions.js.map +1 -0
- package/esm/{fare-table.js → components/fare-table.js} +6 -6
- package/esm/components/fare-table.js.map +1 -0
- package/esm/components/fares.js +151 -0
- package/esm/components/fares.js.map +1 -0
- package/esm/components/flex-booking-info.js +51 -0
- package/esm/components/flex-booking-info.js.map +1 -0
- package/esm/components/time-active.js +69 -0
- package/esm/components/time-active.js.map +1 -0
- package/esm/index.js +40 -289
- package/esm/index.js.map +1 -1
- package/esm/trip-detail.js +4 -2
- package/esm/trip-detail.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/lib/components/departure-date.d.ts +10 -0
- package/lib/components/departure-date.d.ts.map +1 -0
- package/lib/components/departure-date.js +51 -0
- package/lib/components/departure-date.js.map +1 -0
- package/lib/components/emissions.d.ts +8 -0
- package/lib/components/emissions.d.ts.map +1 -0
- package/lib/components/emissions.js +75 -0
- package/lib/components/emissions.js.map +1 -0
- package/lib/{fare-table.d.ts → components/fare-table.d.ts} +1 -1
- package/lib/components/fare-table.d.ts.map +1 -0
- package/lib/{fare-table.js → components/fare-table.js} +6 -6
- package/lib/components/fare-table.js.map +1 -0
- package/lib/components/fares.d.ts +10 -0
- package/lib/components/fares.d.ts.map +1 -0
- package/lib/components/fares.js +162 -0
- package/lib/components/fares.js.map +1 -0
- package/lib/components/flex-booking-info.d.ts +6 -0
- package/lib/components/flex-booking-info.d.ts.map +1 -0
- package/lib/components/flex-booking-info.js +47 -0
- package/lib/components/flex-booking-info.js.map +1 -0
- package/lib/components/time-active.d.ts +14 -0
- package/lib/components/time-active.d.ts.map +1 -0
- package/lib/components/time-active.js +79 -0
- package/lib/components/time-active.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +27 -262
- package/lib/index.js.map +1 -1
- package/lib/trip-detail.d.ts +2 -1
- package/lib/trip-detail.d.ts.map +1 -1
- package/lib/trip-detail.js +4 -2
- package/lib/trip-detail.js.map +1 -1
- package/lib/types.d.ts +20 -19
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +3 -3
- package/src/TripDetails.story.tsx +26 -28
- package/src/__snapshots__/TripDetails.story.tsx.snap +108 -108
- package/src/components/departure-date.tsx +53 -0
- package/src/components/emissions.tsx +97 -0
- package/src/{fare-table.tsx → components/fare-table.tsx} +4 -4
- package/src/components/fares.tsx +205 -0
- package/src/components/flex-booking-info.tsx +57 -0
- package/src/components/time-active.tsx +90 -0
- package/src/index.tsx +28 -365
- package/src/trip-detail.tsx +8 -2
- package/src/types.ts +18 -17
- package/tsconfig.tsbuildinfo +1 -1
- package/esm/fare-table.js.map +0 -1
- package/lib/fare-table.d.ts.map +0 -1
- package/lib/fare-table.js.map +0 -1
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import flatten from "flat";
|
|
2
2
|
import React, { ReactElement } from "react";
|
|
3
3
|
import { FormattedDate } from "react-intl";
|
|
4
|
-
import {
|
|
5
|
-
ComponentStory,
|
|
6
|
-
Meta,
|
|
7
|
-
Parameters,
|
|
8
|
-
StoryContext
|
|
9
|
-
} from "@storybook/react";
|
|
4
|
+
import { Meta, Parameters, StoryContext, StoryObj } from "@storybook/react";
|
|
10
5
|
import styled from "styled-components";
|
|
11
6
|
import { convertGraphQLResponseToLegacy } from "@opentripplanner/core-utils/lib/itinerary";
|
|
12
7
|
// The below eslint-disable is due to https://github.com/storybookjs/storybook/issues/13408
|
|
@@ -144,11 +139,14 @@ const defaultCo2Config = {
|
|
|
144
139
|
};
|
|
145
140
|
|
|
146
141
|
const CustomFareDetails = ({
|
|
147
|
-
|
|
142
|
+
legs,
|
|
143
|
+
maxTNCFare,
|
|
144
|
+
minTNCFare
|
|
148
145
|
}: FareDetailsProps): ReactElement => (
|
|
149
146
|
<>
|
|
150
|
-
Custom details about fares (
|
|
151
|
-
(cents), can be constructed
|
|
147
|
+
Custom details about fares (legs: {JSON.stringify(legs)}, maxTNCFare:{" "}
|
|
148
|
+
{maxTNCFare}, minTNCFare: {minTNCFare}) (cents), can be constructed
|
|
149
|
+
dynamically using any markup.
|
|
152
150
|
</>
|
|
153
151
|
);
|
|
154
152
|
|
|
@@ -182,13 +180,12 @@ const CustomTimeActiveDetails = ({
|
|
|
182
180
|
*/
|
|
183
181
|
function createTripDetailsTemplate(
|
|
184
182
|
Component: typeof TripDetails = TripDetails
|
|
185
|
-
):
|
|
183
|
+
): StoryObj<typeof TripDetails> {
|
|
186
184
|
const TripDetailsTemplate = (
|
|
187
185
|
{
|
|
188
|
-
defaultFareType,
|
|
189
186
|
DepartureDetails,
|
|
190
187
|
FareDetails,
|
|
191
|
-
|
|
188
|
+
fareConfig = {},
|
|
192
189
|
itinerary,
|
|
193
190
|
TimeActiveDetails,
|
|
194
191
|
showApproximateMinutesActive
|
|
@@ -197,21 +194,18 @@ function createTripDetailsTemplate(
|
|
|
197
194
|
): ReactElement => {
|
|
198
195
|
const { locale } = globals;
|
|
199
196
|
const { useCustomFareKeyMap } = parameters;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
? englishFareKeyMap
|
|
203
|
-
|
|
204
|
-
: {};
|
|
197
|
+
if (useCustomFareKeyMap) {
|
|
198
|
+
fareConfig.fareKeyNameMap =
|
|
199
|
+
locale === "en-US" ? englishFareKeyMap : frenchFareKeyMap;
|
|
200
|
+
}
|
|
205
201
|
return (
|
|
206
202
|
<Component
|
|
207
203
|
TimeActiveDetails={TimeActiveDetails}
|
|
208
204
|
DepartureDetails={DepartureDetails}
|
|
209
205
|
FareDetails={FareDetails}
|
|
210
|
-
|
|
211
|
-
fareKeyNameMap={fareKeyNameMap}
|
|
206
|
+
fareConfig={fareConfig}
|
|
212
207
|
itinerary={itinerary}
|
|
213
208
|
co2Config={defaultCo2Config}
|
|
214
|
-
defaultFareType={defaultFareType}
|
|
215
209
|
showApproximateMinutesActive={showApproximateMinutesActive}
|
|
216
210
|
/>
|
|
217
211
|
);
|
|
@@ -226,7 +220,7 @@ function makeStory(
|
|
|
226
220
|
args: TripDetailsProps,
|
|
227
221
|
parameters?: Parameters,
|
|
228
222
|
Component?: typeof TripDetails
|
|
229
|
-
):
|
|
223
|
+
): StoryObj<typeof TripDetails> {
|
|
230
224
|
const BoundTripDetails = createTripDetailsTemplate(Component).bind({});
|
|
231
225
|
BoundTripDetails.args = args;
|
|
232
226
|
BoundTripDetails.parameters = parameters;
|
|
@@ -271,13 +265,15 @@ export const StyledItinerary = makeStory(
|
|
|
271
265
|
{
|
|
272
266
|
itinerary: walkTransitWalkItinerary
|
|
273
267
|
},
|
|
274
|
-
|
|
268
|
+
undefined,
|
|
275
269
|
StyledTripDetails
|
|
276
270
|
);
|
|
277
271
|
|
|
278
272
|
export const LegFareProductsItinerary = makeStory({
|
|
279
|
-
|
|
280
|
-
|
|
273
|
+
fareConfig: {
|
|
274
|
+
defaultFareType: orcaDefaultFareType,
|
|
275
|
+
fareDetailsLayout: orcaFareByLegLayout
|
|
276
|
+
},
|
|
281
277
|
itinerary: otp2FareProducts
|
|
282
278
|
});
|
|
283
279
|
|
|
@@ -299,10 +295,12 @@ export const TncTransitItinerary = makeStory(
|
|
|
299
295
|
|
|
300
296
|
export const TncTransitItineraryWithCustomMessages = makeStory(
|
|
301
297
|
{
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
298
|
+
fareConfig: {
|
|
299
|
+
defaultFareType: {
|
|
300
|
+
headerKey: "electronicRegular",
|
|
301
|
+
mediumId: "orca:electronic",
|
|
302
|
+
riderCategoryId: "orca:regular"
|
|
303
|
+
}
|
|
306
304
|
},
|
|
307
305
|
DepartureDetails: CustomDepartureDetails,
|
|
308
306
|
itinerary: tncTransitTncItinerary,
|