@opentripplanner/trip-details 5.0.0-alpha.6 → 5.0.0-alpha.8
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/__mocks__/custom-english-messages.yml +4 -4
- package/__mocks__/custom-french-messages.yml +7 -8
- package/esm/index.js +8 -9
- package/esm/index.js.map +1 -1
- package/esm/utils.js.map +1 -1
- package/i18n/en-US.yml +0 -8
- package/i18n/es.yml +7 -8
- package/i18n/fr.yml +1 -9
- package/i18n/i18n-exceptions.json +12 -0
- package/i18n/ko.yml +7 -8
- package/i18n/nb_NO.yml +1 -1
- package/i18n/vi.yml +7 -8
- package/i18n/zh_Hans.yml +6 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -11
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +10 -21
- package/lib/types.d.ts.map +1 -1
- package/lib/utils.d.ts +2 -2
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/TripDetails.story.tsx +34 -88
- package/src/index.tsx +9 -10
- package/src/types.ts +15 -23
- package/src/utils.tsx +2 -2
- package/tsconfig.tsbuildinfo +1 -1
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx"],"names":["defaultMessages","defaultEnglishMessages","CO2DescriptionLink","contents","DefaultTimeActiveDetails","bikeMinutes","walkMinutes","strong","boldText","TripDetails","className","co2Config","defaultFareType","DepartureDetails","displayTimeActive","FareDetails","fareDetailsLayout","fareKeyNameMap","itinerary","TimeActiveDetails","fareResult","coreUtils","calculateTncFares","currencyCode","maxTNCFare","minTNCFare","companies","fareTypes","legs","reduce","prev","leg","rideHailingEstimate","provider","id","fareProducts","forEach","fp","mediumId","product","medium","riderCategoryId","riderCategory","find","ft","push","fare","length","defaultFareTotal","TransitFareWrapper","S","TransitFare","TransitFareSingle","fareNameFallback","amount","display","name","headerKey","value","currency","code","map","fareType","Object","values","join","digits","tncFare","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","minutes","link","extraMessage","Set","message"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;AACA;;AACA;;AACA;;AAKA;;;;;;AADA;AAGA;AACA;AACA;AACA;AACA,MAAMA,eAAuC,GAAG,mBAAQC,aAAR,CAAhD;;AAEA,SAASC,kBAAT,CAA4BC,QAA5B,EAAkE;AAChE,sBACE;AACE,IAAA,IAAI,EAAC,2FADP;AAEE,IAAA,GAAG,EAAC,qBAFN;AAGE,IAAA,MAAM,EAAC;AAHT,KAKGA,QALH,CADF;AASD;AACD;AACA;AACA;AACA;;;AACA,SAASC,wBAAT,CAAkC;AAChCC,EAAAA,WADgC;AAEhCC,EAAAA;AAFgC,CAAlC,EAGyC;AACvC,sBACE,6BAAC,2BAAD;AACE,IAAA,cAAc,EACZN,eAAe,CAAC,yCAAD,CAFnB;AAIE,IAAA,WAAW,EAAC,6DAJd;AAKE,IAAA,EAAE,EAAC,yCALL;AAME,IAAA,MAAM,EAAE;AACNK,MAAAA,WADM;AAENE,MAAAA,MAAM,EAAEC,eAFF;AAGNF,MAAAA;AAHM;AANV,IADF;AAcD;AAED;AACA;AACA;;;AACO,SAASG,WAAT,CAAqB;AAC1BC,EAAAA,SAAS,GAAG,EADc;AAE1BC,EAAAA,SAF0B;AAG1BC,EAAAA,eAH0B;AAI1BC,EAAAA,gBAAgB,GAAG,IAJO;AAK1BC,EAAAA,iBAAiB,GAAG,IALM;AAM1BC,EAAAA,WAAW,GAAG,IANY;AAO1BC,EAAAA,iBAP0B;AAQ1BC,EAAAA,cAAc,GAAG,EARS;AAS1BC,EAAAA,SAT0B;AAU1B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AA,EAAE,EAAC,oCALL;AAME,MAAA,MAAM,EAAE;AACNiG,QAAAA,YAAY,EAAE,CACZ,GAAG,IAAIC,GAAJ,CAAQ,CACT,GAAGV,iBAAiB,CAAC3B,GAAlB,CAAsB6B,IAAI,IAAIA,IAAI,CAACS,OAAnC,CADM,EAET,GAAGR,kBAAkB,CAAC9B,GAAnB,CAAuB6B,IAAI,IAAIA,IAAI,CAACS,OAApC,CAFM,CAAR,CADS,EAKZlC,IALY,CAKP,GALO;AADR;AANV,MADF,CAFJ;AAoBE,IAAA,IAAI,eAAE,6BAAC,YAAD;AAAO,MAAA,IAAI,EAAE;AAAb;AApBR,IAzHJ,CATF,CADF;AA6JD;;eAEcxD,W,EAEf","sourcesContent":["import coreUtils from \"@opentripplanner/core-utils\";\nimport React, { ReactElement } 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\";\n\nimport { getItineraryCost } from \"@opentripplanner/core-utils/lib/itinerary\";\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 { FareType, 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: ReactElement): 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 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 // Depending on if there are additional fares to display either render a <span> or a <details>.\n const { companies, fareTypes } = itinerary.legs.reduce<{\n companies: string;\n fareTypes: FareType[];\n }>(\n (prev, leg) => {\n if (leg.rideHailingEstimate) {\n prev.companies = leg.rideHailingEstimate.provider.id;\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 = 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.amount && (\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 key={Object.values(fareType).join(\"-\")}\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] ||\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 maxTNCFare={maxTNCFare}\n minTNCFare={minTNCFare}\n legs={itinerary.legs}\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 maxTNCFare={maxTNCFare}\n minTNCFare={minTNCFare}\n legs={itinerary.legs}\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 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"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["defaultMessages","defaultEnglishMessages","CO2DescriptionLink","contents","DefaultTimeActiveDetails","bikeMinutes","walkMinutes","strong","boldText","TripDetails","className","co2Config","defaultFareType","DepartureDetails","displayTimeActive","FareDetails","fareDetailsLayout","fareKeyNameMap","itinerary","TimeActiveDetails","fareResult","coreUtils","calculateTncFares","currencyCode","maxTNCFare","minTNCFare","companies","fareTypes","legs","reduce","prev","leg","rideHailingEstimate","provider","id","fareProducts","forEach","fp","mediumId","product","medium","riderCategoryId","riderCategory","find","ft","push","fare","length","defaultFareTotal","getItineraryCost","TransitFareWrapper","S","TransitFare","TransitFareSingle","fareNameFallback","amount","display","name","headerKey","value","currency","code","map","fareType","Object","values","join","digits","tncFare","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","minutes","link","extraMessage","Set","message"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AACA;;AACA;;AACA;;AAKA;;;;;;AADA;AAGA;AACA;AACA;AACA;AACA,MAAMA,eAAuC,GAAG,mBAAQC,aAAR,CAAhD;;AAEA,SAASC,kBAAT,CAA4BC,QAA5B,EAAkE;AAChE,sBACE;AACE,IAAA,IAAI,EAAC,2FADP;AAEE,IAAA,GAAG,EAAC,qBAFN;AAGE,IAAA,MAAM,EAAC;AAHT,KAKGA,QALH,CADF;AASD;AACD;AACA;AACA;AACA;;;AACA,SAASC,wBAAT,CAAkC;AAChCC,EAAAA,WADgC;AAEhCC,EAAAA;AAFgC,CAAlC,EAGyC;AACvC,sBACE,6BAAC,2BAAD;AACE,IAAA,cAAc,EACZN,eAAe,CAAC,yCAAD,CAFnB;AAIE,IAAA,WAAW,EAAC,6DAJd;AAKE,IAAA,EAAE,EAAC,yCALL;AAME,IAAA,MAAM,EAAE;AACNK,MAAAA,WADM;AAENE,MAAAA,MAAM,EAAEC,eAFF;AAGNF,MAAAA;AAHM;AANV,IADF;AAcD;AAED;AACA;AACA;;;AACO,SAASG,WAAT,CAAqB;AAC1BC,EAAAA,SAAS,GAAG,EADc;AAE1BC,EAAAA,SAF0B;AAG1BC,EAAAA,eAH0B;AAI1BC,EAAAA,gBAAgB,GAAG,IAJO;AAK1BC,EAAAA,iBAAiB,GAAG,IALM;AAM1BC,EAAAA,WAAW,GAAG,IANY;AAO1BC,EAAAA,iBAP0B;AAQ1BC,EAAAA,cAAc,GAAG,EARS;AAS1BC,EAAAA,SAT0B;AAU1BC,EAAAA,iBAAiB,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CAAC,oCAAD,CAFnB;AAIE,MAAA,WAAW,EAAC,oFAJd;AAKE,MAAA,EAAE,EAAC,oCALL;AAME,MAAA,MAAM,EAAE;AACNkG,QAAAA,YAAY,EAAE,CACZ,GAAG,IAAIC,GAAJ,CAAQ,CACT,GAAGV,iBAAiB,CAAC3B,GAAlB,CAAsB6B,IAAI,IAAIA,IAAI,CAACS,OAAnC,CADM,EAET,GAAGR,kBAAkB,CAAC9B,GAAnB,CAAuB6B,IAAI,IAAIA,IAAI,CAACS,OAApC,CAFM,CAAR,CADS,EAKZlC,IALY,CAKP,GALO;AADR;AANV,MADF,CAFJ;AAoBE,IAAA,IAAI,eAAE,6BAAC,YAAD;AAAO,MAAA,IAAI,EAAE;AAAb;AApBR,IAzHJ,CATF,CADF;AA6JD;;eAEczD,W,EAEf","sourcesContent":["import coreUtils from \"@opentripplanner/core-utils\";\nimport { FareProductSelector } from \"@opentripplanner/types\";\nimport React, { ReactElement } 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: ReactElement): 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 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?.amount && (\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 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"],"file":"index.js"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { FareProductSelector, Itinerary, Leg, MassUnitOption, Money } from "@opentripplanner/types";
|
|
3
3
|
export interface TimeActiveDetailsProps {
|
|
4
4
|
bikeMinutes: number;
|
|
5
5
|
minutesActive?: number;
|
|
@@ -13,42 +13,31 @@ export interface CO2ConfigType {
|
|
|
13
13
|
export interface DepartureDetailsProps {
|
|
14
14
|
departureDate: Date;
|
|
15
15
|
}
|
|
16
|
-
export interface FareType {
|
|
17
|
-
riderCategoryId: string;
|
|
18
|
-
mediumId: string;
|
|
19
|
-
}
|
|
20
16
|
/**
|
|
21
17
|
* This is the interface used to define the layout for a particular fare table.
|
|
22
|
-
* The table with be rendered with the
|
|
18
|
+
* The table with be rendered with the columns defined here,
|
|
23
19
|
* with each row being an individual transit leg from the itinerary.
|
|
24
20
|
*/
|
|
25
21
|
export interface FareTableLayout {
|
|
26
|
-
cols: (
|
|
22
|
+
cols: (FareProductSelector & {
|
|
27
23
|
columnHeaderKey: string;
|
|
28
24
|
})[];
|
|
29
25
|
headerKey: string;
|
|
30
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Interface containing the lgs and the layout of the fare table.
|
|
29
|
+
*/
|
|
31
30
|
export interface FareLegTableProps {
|
|
32
31
|
layout?: FareTableLayout[];
|
|
33
32
|
legs: Leg[];
|
|
34
33
|
}
|
|
35
|
-
export declare type FareTotals = (
|
|
34
|
+
export declare type FareTotals = (FareProductSelector & {
|
|
36
35
|
price: Money;
|
|
37
36
|
})[];
|
|
38
|
-
export interface TransitFareProps {
|
|
39
|
-
headerKey: string;
|
|
40
|
-
fareMediumId: string;
|
|
41
|
-
riderCategoryId: string;
|
|
42
|
-
fareNameFallback?: ReactElement;
|
|
43
|
-
fareKeyNameMap: {
|
|
44
|
-
[key: string]: string;
|
|
45
|
-
};
|
|
46
|
-
fareTotals: FareTotals;
|
|
47
|
-
}
|
|
48
37
|
export interface FareDetailsProps {
|
|
38
|
+
legs: Leg[];
|
|
49
39
|
maxTNCFare: number;
|
|
50
40
|
minTNCFare: number;
|
|
51
|
-
legs: Leg[];
|
|
52
41
|
}
|
|
53
42
|
export interface TripDetailsProps {
|
|
54
43
|
/**
|
|
@@ -64,7 +53,7 @@ export interface TripDetailsProps {
|
|
|
64
53
|
*/
|
|
65
54
|
defaultFareType?: {
|
|
66
55
|
headerKey: string;
|
|
67
|
-
} &
|
|
56
|
+
} & FareProductSelector;
|
|
68
57
|
/**
|
|
69
58
|
* Slot for a custom component to render the expandable section for departure.
|
|
70
59
|
*/
|
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,
|
|
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,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,CAAC,mBAAmB,GAAG;QAC3B,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC,EAAE,CAAA;IACJ,SAAS,EAAE,MAAM,CAAC;CACnB;AACD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;IAC3B,IAAI,EAAE,GAAG,EAAE,CAAC;CACb;AAGD,oBAAY,UAAU,GAAG,CAAC,mBAAmB,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,EAAE,CAAA;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAGD,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACjB;;KAEC;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B;;OAEG;IACH,eAAe,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,mBAAmB,CAAC;IAC9D;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAC5D;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAClD;;OAEG;IACH,iBAAiB,CAAC,EAAE,eAAe,EAAE,CAAC;IACtC;;OAEG;IACH,cAAc,CAAC,EAAE;QACf,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;KACxB,CAAC;IACF;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;IACnB;;KAEC;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;CAC/D"}
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ReactElement } from "react";
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
2
|
/**
|
|
3
3
|
* Format text bold (used with FormattedMessage).
|
|
4
4
|
*/
|
|
5
|
-
export declare function boldText(contents:
|
|
5
|
+
export declare function boldText(contents: ReactNode): ReactElement;
|
|
6
6
|
/**
|
|
7
7
|
* Render formatted fare.
|
|
8
8
|
* @param currencyCode The ISO currency code to use (USD, GBP, EUR).
|
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,YAAY,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAa3E"}
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.tsx"],"names":["boldText","contents","renderFare","currencyCode","fare"],"mappings":";;;;;;;;;;AAAA;;AACA;;AAEA;AACA;AACA;AACO,SAASA,QAAT,CAAkBC,QAAlB,
|
|
1
|
+
{"version":3,"sources":["../src/utils.tsx"],"names":["boldText","contents","renderFare","currencyCode","fare"],"mappings":";;;;;;;;;;AAAA;;AACA;;AAEA;AACA;AACA;AACO,SAASA,QAAT,CAAkBC,QAAlB,EAAqD;AAC1D,sBAAO,6CAASA,QAAT,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,UAAT,CAAoBC,YAApB,EAA0CC,IAA1C,EAAsE;AAC3E,sBACE,6BAAC,0BAAD;AACE,IAAA,QAAQ,EAAED,YADZ,CAEE;AACA;AACA;AAJF;AAKE,IAAA,eAAe,EAAC,cALlB;AAME,IAAA,KAAK,EAAEC,IANT,CAOE;AAPF;AAQE,IAAA,KAAK,EAAC;AARR,IADF;AAYD","sourcesContent":["import React, { ReactElement, ReactNode } from \"react\";\nimport { FormattedNumber } from \"react-intl\";\n\n/**\n * Format text bold (used with FormattedMessage).\n */\nexport function boldText(contents: ReactNode): ReactElement {\n return <strong>{contents}</strong>;\n}\n\n/**\n * Render formatted fare.\n * @param currencyCode The ISO currency code to use (USD, GBP, EUR).\n * @param fare The fare value, in currency units, to be shown.\n * @returns The formatted fare value according to the selected locale.\n */\nexport function renderFare(currencyCode: string, fare: number): ReactElement {\n return (\n <FormattedNumber\n currency={currencyCode}\n // For dollars in locales such as 'fr',\n // this will limit the display to just the dollar sign\n // (otherwise it will render e.g. '2,50 $US' instead of '2,50 $').\n currencyDisplay=\"narrowSymbol\"\n value={fare}\n // eslint-disable-next-line react/style-prop-object\n style=\"currency\"\n />\n );\n}\n"],"file":"utils.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentripplanner/trip-details",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.8",
|
|
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",
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"private": false,
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@opentripplanner/core-utils": "^9.0.0-alpha.
|
|
14
|
+
"@opentripplanner/core-utils": "^9.0.0-alpha.36",
|
|
15
15
|
"@styled-icons/fa-solid": "^10.34.0",
|
|
16
16
|
"flat": "^5.0.2",
|
|
17
17
|
"react-animate-height": "^3.0.4"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@opentripplanner/types": "6.0.0-alpha.
|
|
20
|
+
"@opentripplanner/types": "^6.0.0-alpha.9",
|
|
21
21
|
"@types/flat": "^5.0.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
@@ -26,18 +26,10 @@ import customFrenchMessages from "../__mocks__/custom-french-messages.yml";
|
|
|
26
26
|
|
|
27
27
|
// import mock itinaries. These are all trip plan outputs from OTP.
|
|
28
28
|
const bikeOnlyItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/bike-only.json");
|
|
29
|
-
const bikeRentalItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/bike-rental.json");
|
|
30
|
-
const bikeRentalTransitBikeRentalItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/bike-rental-transit-bike-rental.json");
|
|
31
|
-
const bikeTransitBikeItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/bike-transit-bike.json");
|
|
32
|
-
const eScooterRentalItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/e-scooter-rental.json");
|
|
33
|
-
const eScooterRentalTransiteScooterRentalItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/e-scooter-transit-e-scooter.json");
|
|
34
|
-
const parkAndRideItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/park-and-ride.json");
|
|
35
29
|
const tncTransitTncItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/tnc-transit-tnc.json");
|
|
36
|
-
const walkInterlinedTransitItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/walk-interlined-transit-walk.json");
|
|
37
30
|
const walkOnlyItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/walk-only.json");
|
|
38
31
|
const walkTransitWalkItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/walk-transit-walk.json");
|
|
39
32
|
const walkTransitWalkTransitWalkItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/walk-transit-walk-transit-walk.json");
|
|
40
|
-
const fareProductsItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/leg-fare-products.json");
|
|
41
33
|
const flexItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/flex-itinerary.json");
|
|
42
34
|
const otp2ScooterItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/otp2-scooter.json");
|
|
43
35
|
const otp2FareProducts = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/leg-fare-products.json");
|
|
@@ -57,60 +49,65 @@ const StyledTripDetails = styled(TripDetails)`
|
|
|
57
49
|
}
|
|
58
50
|
`;
|
|
59
51
|
|
|
60
|
-
const
|
|
52
|
+
const orcaFareByLegLayout: FareTableLayout[] = [
|
|
61
53
|
{
|
|
62
|
-
headerKey: "regular",
|
|
63
54
|
cols: [
|
|
64
55
|
{
|
|
65
56
|
columnHeaderKey: "cash",
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
mediumId: "orca:cash",
|
|
58
|
+
riderCategoryId: "orca:regular"
|
|
68
59
|
},
|
|
69
60
|
{
|
|
70
61
|
columnHeaderKey: "electronic",
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
mediumId: "orca:electronic",
|
|
63
|
+
riderCategoryId: "orca:regular"
|
|
73
64
|
},
|
|
74
65
|
{
|
|
75
66
|
columnHeaderKey: "special",
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
mediumId: "orca:electronic",
|
|
68
|
+
riderCategoryId: "orca:special"
|
|
78
69
|
}
|
|
79
|
-
]
|
|
70
|
+
],
|
|
71
|
+
headerKey: "regular"
|
|
80
72
|
},
|
|
81
73
|
{
|
|
82
|
-
headerKey: "youth",
|
|
83
74
|
cols: [
|
|
84
75
|
{
|
|
85
76
|
columnHeaderKey: "cash",
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
mediumId: "orca:cash",
|
|
78
|
+
riderCategoryId: "orca:youth"
|
|
88
79
|
},
|
|
89
80
|
{
|
|
90
81
|
columnHeaderKey: "electronic",
|
|
91
|
-
|
|
92
|
-
|
|
82
|
+
mediumId: "orca:electronic",
|
|
83
|
+
riderCategoryId: "orca:youth"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
columnHeaderKey: "test",
|
|
87
|
+
mediumId: "invalidkey",
|
|
88
|
+
riderCategoryId: "invalidkey"
|
|
93
89
|
}
|
|
94
|
-
]
|
|
90
|
+
],
|
|
91
|
+
headerKey: "youth"
|
|
95
92
|
},
|
|
96
93
|
{
|
|
97
94
|
headerKey: "senior",
|
|
98
95
|
cols: [
|
|
99
96
|
{
|
|
100
97
|
columnHeaderKey: "cash",
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
mediumId: "orca:cash",
|
|
99
|
+
riderCategoryId: "orca:senior"
|
|
103
100
|
},
|
|
104
101
|
{
|
|
105
102
|
columnHeaderKey: "electronic",
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
mediumId: "orca:electronic",
|
|
104
|
+
riderCategoryId: "orca:senior"
|
|
108
105
|
}
|
|
109
106
|
]
|
|
110
107
|
}
|
|
111
108
|
];
|
|
112
109
|
|
|
113
|
-
const
|
|
110
|
+
const orcaDefaultFareType = {
|
|
114
111
|
headerKey: "cash-regular",
|
|
115
112
|
mediumId: "orca:cash",
|
|
116
113
|
riderCategoryId: "orca:regular"
|
|
@@ -188,11 +185,11 @@ function createTripDetailsTemplate(
|
|
|
188
185
|
): ComponentStory<typeof TripDetails> {
|
|
189
186
|
const TripDetailsTemplate = (
|
|
190
187
|
{
|
|
191
|
-
|
|
188
|
+
defaultFareType,
|
|
192
189
|
DepartureDetails,
|
|
193
190
|
FareDetails,
|
|
194
191
|
fareDetailsLayout,
|
|
195
|
-
|
|
192
|
+
TimeActiveDetails,
|
|
196
193
|
itinerary
|
|
197
194
|
}: TripDetailsProps,
|
|
198
195
|
{ globals, parameters }: StoryContext
|
|
@@ -262,7 +259,7 @@ export const WalkTransitWalkItinerary = makeStory({
|
|
|
262
259
|
itinerary: walkTransitWalkItinerary
|
|
263
260
|
});
|
|
264
261
|
|
|
265
|
-
export const
|
|
262
|
+
export const StyledItinerary = makeStory(
|
|
266
263
|
{
|
|
267
264
|
itinerary: walkTransitWalkItinerary
|
|
268
265
|
},
|
|
@@ -270,57 +267,10 @@ export const StyledWalkTransitWalkItinerary = makeStory(
|
|
|
270
267
|
StyledTripDetails
|
|
271
268
|
);
|
|
272
269
|
|
|
273
|
-
export const BikeTransitBikeItinerary = makeStory({
|
|
274
|
-
itinerary: bikeTransitBikeItinerary
|
|
275
|
-
});
|
|
276
|
-
|
|
277
270
|
export const LegFareProductsItinerary = makeStory({
|
|
278
|
-
|
|
279
|
-
fareDetailsLayout:
|
|
280
|
-
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
export const WalkInterlinedTransitItinerary = makeStory(
|
|
284
|
-
{
|
|
285
|
-
// defaultFareKey: "electronicRegular",
|
|
286
|
-
// fareDetailsLayout: fareByLegLayout,
|
|
287
|
-
itinerary: walkInterlinedTransitItinerary
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
useCustomFareKeyMap: true,
|
|
291
|
-
// For illustration purposes,
|
|
292
|
-
// override a subset of localized strings with custom messages.
|
|
293
|
-
reactIntl: {
|
|
294
|
-
messages: {
|
|
295
|
-
"en-US": flattenedEnglishMessages,
|
|
296
|
-
fr: flattenedFrenchMessages
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
);
|
|
301
|
-
|
|
302
|
-
export const WalkTransitTransferItinerary = makeStory({
|
|
303
|
-
itinerary: walkTransitWalkTransitWalkItinerary
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
export const BikeRentalItinerary = makeStory({
|
|
307
|
-
itinerary: bikeRentalItinerary
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
export const EScooterRentalItinerary = makeStory({
|
|
311
|
-
itinerary: eScooterRentalItinerary
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
export const ParkAndRideItinerary = makeStory({
|
|
315
|
-
itinerary: parkAndRideItinerary
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
export const BikeRentalTransitItinerary = makeStory({
|
|
319
|
-
itinerary: bikeRentalTransitBikeRentalItinerary
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
export const EScooterRentalTransitItinerary = makeStory({
|
|
323
|
-
itinerary: eScooterRentalTransiteScooterRentalItinerary
|
|
271
|
+
defaultFareType: orcaDefaultFareType,
|
|
272
|
+
fareDetailsLayout: orcaFareByLegLayout,
|
|
273
|
+
itinerary: otp2FareProducts
|
|
324
274
|
});
|
|
325
275
|
|
|
326
276
|
// The render of this itinerary is uninteresting, but the test
|
|
@@ -341,14 +291,14 @@ export const TncTransitItinerary = makeStory(
|
|
|
341
291
|
|
|
342
292
|
export const TncTransitItineraryWithCustomMessages = makeStory(
|
|
343
293
|
{
|
|
344
|
-
TimeActiveDetails: CustomTimeActiveDetails,
|
|
345
294
|
defaultFareType: {
|
|
346
295
|
headerKey: "electronicRegular",
|
|
347
296
|
mediumId: "orca:electronic",
|
|
348
297
|
riderCategoryId: "orca:regular"
|
|
349
298
|
},
|
|
350
299
|
DepartureDetails: CustomDepartureDetails,
|
|
351
|
-
itinerary: tncTransitTncItinerary
|
|
300
|
+
itinerary: tncTransitTncItinerary,
|
|
301
|
+
TimeActiveDetails: CustomTimeActiveDetails
|
|
352
302
|
},
|
|
353
303
|
{
|
|
354
304
|
// For illustration purposes,
|
|
@@ -364,13 +314,9 @@ export const TncTransitItineraryWithCustomMessages = makeStory(
|
|
|
364
314
|
StyledTripDetails
|
|
365
315
|
);
|
|
366
316
|
|
|
367
|
-
export const FareComponentsItinerary = makeStory({
|
|
368
|
-
itinerary: fareProductsItinerary
|
|
369
|
-
});
|
|
370
|
-
|
|
371
317
|
export const OTP2FlexItinerary = makeStory({ itinerary: flexItinerary });
|
|
372
318
|
|
|
373
319
|
export const FareLegTableStoryLegProducts = (): ReactElement => {
|
|
374
320
|
const otp1legs = otp2FareProducts.legs.map(convertGraphQLResponseToLegacy);
|
|
375
|
-
return <FareLegTable layout={
|
|
321
|
+
return <FareLegTable layout={orcaFareByLegLayout} legs={otp1legs} />;
|
|
376
322
|
};
|
package/src/index.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import coreUtils from "@opentripplanner/core-utils";
|
|
2
|
+
import { FareProductSelector } from "@opentripplanner/types";
|
|
2
3
|
import React, { ReactElement } from "react";
|
|
3
4
|
import { FormattedMessage, FormattedNumber } from "react-intl";
|
|
4
5
|
import { CalendarAlt } from "@styled-icons/fa-solid/CalendarAlt";
|
|
@@ -6,15 +7,13 @@ import { Heartbeat } from "@styled-icons/fa-solid/Heartbeat";
|
|
|
6
7
|
import { MoneyBillAlt } from "@styled-icons/fa-solid/MoneyBillAlt";
|
|
7
8
|
import { Leaf } from "@styled-icons/fa-solid/Leaf";
|
|
8
9
|
import { Route } from "@styled-icons/fa-solid/Route";
|
|
9
|
-
|
|
10
|
-
import { getItineraryCost } from "@opentripplanner/core-utils/lib/itinerary";
|
|
11
10
|
import { flatten } from "flat";
|
|
12
11
|
import * as S from "./styled";
|
|
13
12
|
import TripDetail from "./trip-detail";
|
|
14
13
|
import FareLegTable from "./fare-table";
|
|
15
14
|
import { boldText, renderFare } from "./utils";
|
|
16
15
|
|
|
17
|
-
import {
|
|
16
|
+
import { TimeActiveDetailsProps, TripDetailsProps } from "./types";
|
|
18
17
|
|
|
19
18
|
// Load the default messages.
|
|
20
19
|
import defaultEnglishMessages from "../i18n/en-US.yml";
|
|
@@ -79,15 +78,15 @@ export function TripDetails({
|
|
|
79
78
|
const fareResult = coreUtils.itinerary.calculateTncFares(itinerary);
|
|
80
79
|
const { currencyCode, maxTNCFare, minTNCFare } = fareResult;
|
|
81
80
|
|
|
82
|
-
// Depending on if there are additional fares to display either render a <span> or a <details>.
|
|
83
81
|
const { companies, fareTypes } = itinerary.legs.reduce<{
|
|
84
82
|
companies: string;
|
|
85
|
-
fareTypes:
|
|
83
|
+
fareTypes: FareProductSelector[];
|
|
86
84
|
}>(
|
|
87
85
|
(prev, leg) => {
|
|
88
86
|
if (leg.rideHailingEstimate) {
|
|
89
87
|
prev.companies = leg.rideHailingEstimate.provider.id;
|
|
90
88
|
}
|
|
89
|
+
|
|
91
90
|
if (leg.fareProducts) {
|
|
92
91
|
leg.fareProducts.forEach(fp => {
|
|
93
92
|
const mediumId = fp.product?.medium?.id;
|
|
@@ -110,7 +109,7 @@ export function TripDetails({
|
|
|
110
109
|
|
|
111
110
|
let fare;
|
|
112
111
|
if (fareTypes.length > 0 && defaultFareType) {
|
|
113
|
-
const defaultFareTotal = getItineraryCost(
|
|
112
|
+
const defaultFareTotal = coreUtils.itinerary.getItineraryCost(
|
|
114
113
|
itinerary.legs,
|
|
115
114
|
defaultFareType.mediumId,
|
|
116
115
|
defaultFareType.riderCategoryId
|
|
@@ -127,7 +126,7 @@ export function TripDetails({
|
|
|
127
126
|
/>
|
|
128
127
|
);
|
|
129
128
|
|
|
130
|
-
fare = defaultFareTotal
|
|
129
|
+
fare = defaultFareTotal?.amount && (
|
|
131
130
|
<S.Fare>
|
|
132
131
|
<TransitFareWrapper>
|
|
133
132
|
<summary style={{ display: fareTypes.length > 1 ? "list-item" : "" }}>
|
|
@@ -160,12 +159,12 @@ export function TripDetails({
|
|
|
160
159
|
}
|
|
161
160
|
return (
|
|
162
161
|
<FormattedMessage
|
|
163
|
-
key={Object.values(fareType).join("-")}
|
|
164
162
|
defaultMessage={
|
|
165
163
|
defaultMessages["otpUi.TripDetails.transitFareEntry"]
|
|
166
164
|
}
|
|
167
165
|
description="Text showing the price of tickets on public transportation."
|
|
168
166
|
id="otpUi.TripDetails.transitFareEntry"
|
|
167
|
+
key={Object.values(fareType).join("-")}
|
|
169
168
|
values={{
|
|
170
169
|
name:
|
|
171
170
|
fareKeyNameMap[defaultFareType.headerKey] ||
|
|
@@ -284,9 +283,9 @@ export function TripDetails({
|
|
|
284
283
|
description={
|
|
285
284
|
FareDetails && (
|
|
286
285
|
<FareDetails
|
|
286
|
+
legs={itinerary.legs}
|
|
287
287
|
maxTNCFare={maxTNCFare}
|
|
288
288
|
minTNCFare={minTNCFare}
|
|
289
|
-
legs={itinerary.legs}
|
|
290
289
|
/>
|
|
291
290
|
)
|
|
292
291
|
}
|
|
@@ -300,9 +299,9 @@ export function TripDetails({
|
|
|
300
299
|
description={
|
|
301
300
|
FareDetails && (
|
|
302
301
|
<FareDetails
|
|
302
|
+
legs={itinerary.legs}
|
|
303
303
|
maxTNCFare={maxTNCFare}
|
|
304
304
|
minTNCFare={minTNCFare}
|
|
305
|
-
legs={itinerary.legs}
|
|
306
305
|
/>
|
|
307
306
|
)
|
|
308
307
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
// Prettier does not recognize the import type syntax.
|
|
2
2
|
// eslint-disable-next-line prettier/prettier
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type {
|
|
4
|
+
FareProductSelector,
|
|
5
|
+
Itinerary,
|
|
6
|
+
Leg,
|
|
7
|
+
MassUnitOption,
|
|
8
|
+
Money
|
|
9
|
+
} from "@opentripplanner/types";
|
|
5
10
|
|
|
6
11
|
export interface TimeActiveDetailsProps {
|
|
7
12
|
bikeMinutes: number;
|
|
@@ -19,45 +24,32 @@ export interface DepartureDetailsProps {
|
|
|
19
24
|
departureDate: Date;
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
export interface FareType {
|
|
23
|
-
riderCategoryId: string;
|
|
24
|
-
mediumId: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
27
|
/**
|
|
28
28
|
* This is the interface used to define the layout for a particular fare table.
|
|
29
|
-
* The table with be rendered with the
|
|
29
|
+
* The table with be rendered with the columns defined here,
|
|
30
30
|
* with each row being an individual transit leg from the itinerary.
|
|
31
31
|
*/
|
|
32
32
|
export interface FareTableLayout {
|
|
33
|
-
cols: (
|
|
33
|
+
cols: (FareProductSelector & {
|
|
34
34
|
columnHeaderKey: string;
|
|
35
35
|
})[]
|
|
36
36
|
headerKey: string;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Interface containing the lgs and the layout of the fare table.
|
|
40
|
+
*/
|
|
38
41
|
export interface FareLegTableProps {
|
|
39
42
|
layout?: FareTableLayout[];
|
|
40
43
|
legs: Leg[];
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
// Total fare amount corresponding to a fare key
|
|
44
|
-
export type FareTotals = (
|
|
45
|
-
|
|
46
|
-
export interface TransitFareProps {
|
|
47
|
-
headerKey: string;
|
|
48
|
-
fareMediumId: string
|
|
49
|
-
riderCategoryId: string
|
|
50
|
-
fareNameFallback?: ReactElement;
|
|
51
|
-
fareKeyNameMap: {
|
|
52
|
-
[key: string]: string;
|
|
53
|
-
};
|
|
54
|
-
fareTotals: FareTotals;
|
|
55
|
-
}
|
|
47
|
+
export type FareTotals = (FareProductSelector & { price: Money })[]
|
|
56
48
|
|
|
57
49
|
export interface FareDetailsProps {
|
|
50
|
+
legs: Leg[];
|
|
58
51
|
maxTNCFare: number;
|
|
59
52
|
minTNCFare: number;
|
|
60
|
-
legs: Leg[];
|
|
61
53
|
}
|
|
62
54
|
|
|
63
55
|
|
|
@@ -73,7 +65,7 @@ export interface TripDetailsProps {
|
|
|
73
65
|
/**
|
|
74
66
|
* Determines which transit fare should be displayed by default, should there be multiple transit fare types.
|
|
75
67
|
*/
|
|
76
|
-
defaultFareType?: { headerKey: string } &
|
|
68
|
+
defaultFareType?: { headerKey: string } & FareProductSelector;
|
|
77
69
|
/**
|
|
78
70
|
* Slot for a custom component to render the expandable section for departure.
|
|
79
71
|
*/
|