@opentripplanner/trip-details 7.0.1-alpha.1 → 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/i18n/ko.yml +2 -2
- package/i18n/nb_NO.yml +0 -1
- package/i18n/ru.yml +3 -3
- package/i18n/ta.yml +14 -18
- package/i18n/tl.yml +2 -2
- package/i18n/vi.yml +2 -2
- package/i18n/zh_Hans.yml +2 -2
- 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} +5 -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/README.md +0 -6
- 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
package/lib/trip-detail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trip-detail.js","names":["_react","_interopRequireWildcard","require","_QuestionCircle","_TimesCircle","_reactAnimateHeight","_interopRequireDefault","_reactIntl","S","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","isRunningJest","process","env","JEST_WORKER_ID","undefined","uuidv4","replace","c","Math","random","v","toString","TripDetail","icon","summary","description","intl","useIntl","expanded","setExpanded","useState","id","toggle","createElement","role","TripDetailIcon","TripDetailSummary","ExpandButton","formatMessage","onClick","tabIndex","QuestionCircle","size","duration","height","TripDetailDescription","HideButton","TimesCircle","_default","exports"],"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 = ({
|
|
1
|
+
{"version":3,"file":"trip-detail.js","names":["_react","_interopRequireWildcard","require","_QuestionCircle","_TimesCircle","_reactAnimateHeight","_interopRequireDefault","_reactIntl","S","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","isRunningJest","process","env","JEST_WORKER_ID","undefined","uuidv4","replace","c","Math","random","v","toString","TripDetail","icon","summary","description","className","intl","useIntl","expanded","setExpanded","useState","id","toggle","createElement","role","TripDetailIcon","TripDetailSummary","ExpandButton","formatMessage","onClick","tabIndex","QuestionCircle","size","duration","height","TripDetailDescription","HideButton","TimesCircle","_default","exports"],"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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAAG,mBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,CAAA,GAAAP,uBAAA,CAAAC,OAAA;AAA8B,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CA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,CAAA,KAAMV,WAAW,CAAC,KAAK;EAAE,gBAClEjD,MAAA,CAAAe,OAAA,CAAAsC,aAAA,CAACjD,YAAA,CAAA+D,WAAW;IAACL,IAAI,EAAC;EAAQ,CAAE,CAChB,CAAC,EACdlB,WACsB,CACZ,CACH,CAAC;AAEnB,CAAC;AAAC,IAAAwB,QAAA,GAAAC,OAAA,CAAAtD,OAAA,GAEa0B,UAAU","ignoreList":[]}
|
package/lib/types.d.ts
CHANGED
|
@@ -39,6 +39,24 @@ export interface FareDetailsProps {
|
|
|
39
39
|
maxTNCFare: number;
|
|
40
40
|
minTNCFare: number;
|
|
41
41
|
}
|
|
42
|
+
export interface FareConfig {
|
|
43
|
+
/**
|
|
44
|
+
* Determines which transit fare should be displayed by default, should there be multiple transit fare types.
|
|
45
|
+
*/
|
|
46
|
+
defaultFareType?: {
|
|
47
|
+
headerKey: string;
|
|
48
|
+
} & FareProductSelector;
|
|
49
|
+
/**
|
|
50
|
+
* Column and table configuration for fare details/fare by leg table.
|
|
51
|
+
*/
|
|
52
|
+
fareDetailsLayout?: FareTableLayout[];
|
|
53
|
+
/**
|
|
54
|
+
* Mapping between fare keys and human-readable names for them.
|
|
55
|
+
*/
|
|
56
|
+
fareKeyNameMap?: {
|
|
57
|
+
[name: string]: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
42
60
|
export interface TripDetailsProps {
|
|
43
61
|
/**
|
|
44
62
|
* Used for additional styling with styled components for example.
|
|
@@ -48,35 +66,18 @@ export interface TripDetailsProps {
|
|
|
48
66
|
* Object containing the CO₂ config.
|
|
49
67
|
*/
|
|
50
68
|
co2Config?: CO2ConfigType;
|
|
51
|
-
/**
|
|
52
|
-
* Determines which transit fare should be displayed by default, should there be multiple transit fare types.
|
|
53
|
-
*/
|
|
54
|
-
defaultFareType?: {
|
|
55
|
-
headerKey: string;
|
|
56
|
-
} & FareProductSelector;
|
|
57
69
|
/**
|
|
58
70
|
* Slot for a custom component to render the expandable section for departure.
|
|
59
71
|
*/
|
|
60
72
|
DepartureDetails?: React.ElementType<DepartureDetailsProps>;
|
|
61
|
-
/**
|
|
62
|
-
* If this is set to true, a row will be added to the trip details displaying how
|
|
63
|
-
* many minutes in total the user will spend walking or biking.
|
|
64
|
-
*/
|
|
65
|
-
displayTimeActive?: boolean;
|
|
66
73
|
/**
|
|
67
74
|
* Slot for a custom component to render the expandable section for fares.
|
|
68
75
|
*/
|
|
69
76
|
FareDetails?: React.ElementType<FareDetailsProps>;
|
|
70
77
|
/**
|
|
71
|
-
*
|
|
72
|
-
*/
|
|
73
|
-
fareDetailsLayout?: FareTableLayout[];
|
|
74
|
-
/**
|
|
75
|
-
* Mapping between fare keys and human-readable names for them.
|
|
78
|
+
* Configuration for fare details/fare by leg table.
|
|
76
79
|
*/
|
|
77
|
-
|
|
78
|
-
[name: string]: string;
|
|
79
|
-
};
|
|
80
|
+
fareConfig?: FareConfig;
|
|
80
81
|
/**
|
|
81
82
|
* Itinerary that the user has selected to view, contains multiple legs.
|
|
82
83
|
*/
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EACV,mBAAmB,EACnB,SAAS,EACT,GAAG,EACH,cAAc,EACd,KAAK,EACL,MAAM,wBAAwB,CAAC;AAEjC,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,IAAI,CAAC;CACrB;AAED;;;;GAIG;AACH,MA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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\
|
|
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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentripplanner/trip-details",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "A component for displaying details about a trip planning itinerary",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"@styled-icons/fa-solid": "^10.34.0",
|
|
15
15
|
"flat": "^5.0.2",
|
|
16
16
|
"react-animate-height": "^3.0.4",
|
|
17
|
-
"@opentripplanner/core-utils": "
|
|
17
|
+
"@opentripplanner/core-utils": "13.0.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/flat": "^5.0.2",
|
|
21
|
-
"@opentripplanner/types": "
|
|
21
|
+
"@opentripplanner/types": "6.5.3"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "^18.2.0",
|
|
@@ -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,
|