@opentripplanner/trip-details 9.2.0 → 9.3.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/esm/components/departure-date.js +18 -8
  2. package/esm/components/departure-date.js.map +1 -1
  3. package/esm/components/fares-v2-table.js +7 -3
  4. package/esm/components/fares-v2-table.js.map +1 -1
  5. package/esm/components/fares.js +3 -1
  6. package/esm/components/fares.js.map +1 -1
  7. package/esm/components/time-active.js +2 -2
  8. package/esm/components/time-active.js.map +1 -1
  9. package/esm/components/transit-time.js +36 -0
  10. package/esm/components/transit-time.js.map +1 -0
  11. package/esm/index.js +18 -5
  12. package/esm/index.js.map +1 -1
  13. package/esm/types.js.map +1 -1
  14. package/i18n/en-US.yml +6 -0
  15. package/i18n/fr.yml +6 -0
  16. package/lib/components/departure-date.d.ts +3 -2
  17. package/lib/components/departure-date.d.ts.map +1 -1
  18. package/lib/components/departure-date.js +18 -8
  19. package/lib/components/departure-date.js.map +1 -1
  20. package/lib/components/fares-v2-table.d.ts +3 -2
  21. package/lib/components/fares-v2-table.d.ts.map +1 -1
  22. package/lib/components/fares-v2-table.js +6 -4
  23. package/lib/components/fares-v2-table.js.map +1 -1
  24. package/lib/components/fares.d.ts +3 -2
  25. package/lib/components/fares.d.ts.map +1 -1
  26. package/lib/components/fares.js +3 -1
  27. package/lib/components/fares.js.map +1 -1
  28. package/lib/components/time-active.d.ts +3 -3
  29. package/lib/components/time-active.d.ts.map +1 -1
  30. package/lib/components/time-active.js +2 -2
  31. package/lib/components/time-active.js.map +1 -1
  32. package/lib/components/transit-time.d.ts +7 -0
  33. package/lib/components/transit-time.d.ts.map +1 -0
  34. package/lib/components/transit-time.js +40 -0
  35. package/lib/components/transit-time.js.map +1 -0
  36. package/lib/index.d.ts +1 -1
  37. package/lib/index.d.ts.map +1 -1
  38. package/lib/index.js +16 -5
  39. package/lib/index.js.map +1 -1
  40. package/lib/types.d.ts +15 -1
  41. package/lib/types.d.ts.map +1 -1
  42. package/lib/types.js.map +1 -1
  43. package/package.json +3 -3
  44. package/src/TripDetails.story.tsx +40 -5
  45. package/src/__snapshots__/TripDetails.story.tsx.snap +313 -0
  46. package/src/components/departure-date.tsx +24 -13
  47. package/src/components/fares-v2-table.tsx +11 -3
  48. package/src/components/fares.tsx +9 -2
  49. package/src/components/time-active.tsx +4 -4
  50. package/src/components/transit-time.tsx +40 -0
  51. package/src/index.tsx +16 -3
  52. package/src/types.ts +20 -5
  53. package/tsconfig.tsbuildinfo +1 -1
package/src/index.tsx CHANGED
@@ -1,6 +1,7 @@
1
1
  import React, { ReactElement } from "react";
2
2
  import { FormattedMessage } from "react-intl";
3
3
  import { flatten } from "flat";
4
+ import coreUtils from "@opentripplanner/core-utils";
4
5
  import * as S from "./styled";
5
6
  import { TripDetailsProps } from "./types";
6
7
  import FlexBookingInfo from "./components/flex-booking-info";
@@ -9,6 +10,7 @@ import Emissions from "./components/emissions";
9
10
  import Fares from "./components/fares";
10
11
  import TimeActive, { DefaultTimeActiveDetails } from "./components/time-active";
11
12
  import DepartureDate from "./components/departure-date";
13
+ import TransitTime from "./components/transit-time";
12
14
 
13
15
  // Load the default messages.
14
16
  import defaultEnglishMessages from "../i18n/en-US.yml";
@@ -33,9 +35,17 @@ export function TripDetails({
33
35
  DepartureDetails = null,
34
36
  FareDetails = null,
35
37
  itinerary,
38
+ mediumRiderWhitelist,
36
39
  showApproximateMinutesActive,
37
- TimeActiveDetails = DefaultTimeActiveDetails
40
+ showTransitTime = false,
41
+ TimeActiveDetails = DefaultTimeActiveDetails,
42
+ transitOnly = false
38
43
  }: TripDetailsProps): ReactElement {
44
+ const timing = coreUtils.itinerary.getItinerarySummaryTiming(
45
+ itinerary,
46
+ transitOnly
47
+ );
48
+
39
49
  return (
40
50
  <S.TripDetails className={cn(className, "trip-details")}>
41
51
  {/* this can be presentation as S.TripDetails is already labeled by this */}
@@ -49,16 +59,19 @@ export function TripDetails({
49
59
 
50
60
  <S.TripDetailsBody>
51
61
  <DepartureDate
52
- itinerary={itinerary}
62
+ startTime={timing.startTime}
53
63
  DepartureDetails={DepartureDetails}
64
+ isBoarding={transitOnly && timing.legs[0]?.transitLeg === true}
54
65
  />
66
+ {showTransitTime && <TransitTime legs={itinerary.legs} />}
55
67
  <Fares
56
68
  itinerary={itinerary}
57
69
  FareDetails={FareDetails}
58
70
  defaultFareType={defaultFareType}
71
+ mediumRiderWhitelist={mediumRiderWhitelist}
59
72
  />
60
73
  <TimeActive
61
- itinerary={itinerary}
74
+ legs={timing.legs}
62
75
  TimeActiveDetails={TimeActiveDetails}
63
76
  showApproximateMinutesActive={showApproximateMinutesActive}
64
77
  />
package/src/types.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  // Prettier does not recognize the import type syntax.
2
2
  // eslint-disable-next-line prettier/prettier
3
- import type {
4
- FareProductSelector,
5
- Itinerary,
6
- Leg,
3
+ import type {
4
+ FareProductSelector,
5
+ Itinerary,
6
+ Leg,
7
7
  MassUnitOption,
8
+ MediumRiderWhitelist,
8
9
  Money
9
10
  } from "@opentripplanner/types";
10
11
 
@@ -59,12 +60,26 @@ export interface TripDetailsProps {
59
60
  * Itinerary that the user has selected to view, contains multiple legs.
60
61
  */
61
62
  itinerary: Itinerary;
63
+ /**
64
+ * A whitelist of medium-rider pairs to be shown. All others will be hidden.
65
+ */
66
+ mediumRiderWhitelist?: MediumRiderWhitelist;
62
67
  /**
63
68
  * show the '~' symbol in the trip details panel
64
69
  */
65
70
  showApproximateMinutesActive?: boolean;
71
+ /**
72
+ * Show time on board transit vehicles, excluding transfers and waiting.
73
+ */
74
+ showTransitTime?: boolean;
66
75
  /**
67
76
  * Slot for a custom component to render the expandable section for time active.
68
77
  */
69
78
  TimeActiveDetails?: React.ElementType<TimeActiveDetailsProps>;
70
- }
79
+ /**
80
+ * Use the first transit departure and count only transfer activity between
81
+ * the first and last transit legs.
82
+ * Defaults to false. Trips without transit retain their full-journey timing.
83
+ */
84
+ transitOnly?: boolean;
85
+ }