@opentripplanner/trip-details 2.0.0 → 2.0.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.
package/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import flatten from "flat"; // @ts-expect-error FIXME: Create TypeScript types for core-utils packages.
1
+ import flatten from "flat"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-ignore FIXME: Create TypeScript types for core-utils packages.
2
3
 
3
4
  import coreUtils from "@opentripplanner/core-utils";
4
5
  import React from "react";
@@ -114,7 +115,7 @@ var TransitFare = function TransitFare(_ref2) {
114
115
  values: {
115
116
  name: fareKeyNameMap[fareKey] || fareNameFallback || fareKey,
116
117
  strong: boldText,
117
- value: renderFare(currentFare.currencyCode, currentFare.transitFare / 100)
118
+ value: renderFare(currentFare.currency.currencyCode, currentFare.cents / 100)
118
119
  }
119
120
  }));
120
121
  };
@@ -124,6 +125,8 @@ var TransitFare = function TransitFare(_ref2) {
124
125
 
125
126
 
126
127
  export function TripDetails(_ref3) {
128
+ var _itinerary$fare;
129
+
127
130
  var _ref3$CaloriesDetails = _ref3.CaloriesDetails,
128
131
  CaloriesDetails = _ref3$CaloriesDetails === void 0 ? DefaultCaloriesDetails : _ref3$CaloriesDetails,
129
132
  _ref3$className = _ref3.className,
@@ -138,17 +141,11 @@ export function TripDetails(_ref3) {
138
141
  fareKeyNameMap = _ref3$fareKeyNameMap === void 0 ? {} : _ref3$fareKeyNameMap,
139
142
  itinerary = _ref3.itinerary;
140
143
  // process the transit fare
141
- var fareResult = coreUtils.itinerary.calculateFares(itinerary, true);
144
+ var fareResult = coreUtils.itinerary.calculateTncFares(itinerary);
142
145
  var maxTNCFare = fareResult.maxTNCFare,
143
146
  minTNCFare = fareResult.minTNCFare,
144
- tncCurrencyCode = fareResult.tncCurrencyCode,
145
- transitFares = fareResult.transitFares;
146
- var defaultFare = defaultFareKey;
147
-
148
- if (!transitFares[defaultFareKey]) {
149
- defaultFare = "regular";
150
- }
151
-
147
+ tncCurrencyCode = fareResult.tncCurrencyCode;
148
+ var transitFares = itinerary === null || itinerary === void 0 ? void 0 : (_itinerary$fare = itinerary.fare) === null || _itinerary$fare === void 0 ? void 0 : _itinerary$fare.fare;
152
149
  var companies = "";
153
150
  itinerary.legs.forEach(function (leg) {
154
151
  if (leg.tncData) {
@@ -159,7 +156,13 @@ export function TripDetails(_ref3) {
159
156
  var fareKeys = transitFares && Object.keys(transitFares).sort();
160
157
 
161
158
  if (transitFares && fareKeys.length > 0) {
162
- // Depending on if there are additional fares to display either render a <span> or a <details>
159
+ var defaultFare = defaultFareKey;
160
+
161
+ if (!transitFares[defaultFareKey]) {
162
+ defaultFare = "regular";
163
+ } // Depending on if there are additional fares to display either render a <span> or a <details>
164
+
165
+
163
166
  var TransitFareWrapper = transitFares && fareKeys.length > 1 ? S.TransitFare : S.TransitFareSingle;
164
167
  fare = /*#__PURE__*/React.createElement(S.Fare, null, /*#__PURE__*/React.createElement(TransitFareWrapper, null, /*#__PURE__*/React.createElement("summary", {
165
168
  style: {
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.tsx"],"names":["flatten","coreUtils","React","FormattedMessage","FormattedNumber","CalendarAlt","HandPaper","Heartbeat","MoneyBillAlt","PhoneVolume","Route","S","TripDetail","defaultEnglishMessages","defaultMessages","boldText","contents","renderFare","currencyCode","fare","dietaryLink","getFlexMessageValues","info","hasLeadTime","itinerary","isAdvanceBookingRequired","hasPhone","contactInfo","phoneNumber","leadDays","latestBookingTime","daysPrior","DefaultCaloriesDetails","bikeSeconds","calories","walkSeconds","bikeMinutes","Math","round","strong","walkMinutes","TransitFare","fareKey","fareNameFallback","fareKeyNameMap","transitFares","currentFare","name","value","transitFare","TripDetails","CaloriesDetails","className","DepartureDetails","defaultFareKey","FareDetails","fareResult","calculateFares","maxTNCFare","minTNCFare","tncCurrencyCode","defaultFare","companies","legs","forEach","leg","tncData","company","fareKeys","Object","keys","sort","length","TransitFareWrapper","TransitFareSingle","display","map","toLowerCase","departureDate","Date","startTime","calculatePhysicalActivity","bikeDuration","caloriesBurned","walkDuration","containsFlex","some","isFlex","pickupBookingInfo","filter","dropOffBookingInfo","pickupMessage","dropOffMessage","Styled"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,MAApB,C,CACA;;AACA,OAAOC,SAAP,MAAsB,6BAAtB;AAEA,OAAOC,KAAP,MAAoC,OAApC;AACA,SAASC,gBAAT,EAA2BC,eAA3B,QAAkD,YAAlD;AACA,SAASC,WAAT,QAA4B,oCAA5B;AACA,SAASC,SAAT,QAA0B,kCAA1B;AACA,SAASC,SAAT,QAA0B,kCAA1B;AACA,SAASC,YAAT,QAA6B,qCAA7B;AACA,SAASC,WAAT,QAA4B,oCAA5B;AACA,SAASC,KAAT,QAAsB,8BAAtB;AAEA,OAAO,KAAKC,CAAZ,MAAmB,UAAnB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AAQA;AACA,OAAOC,sBAAP,MAAmC,mBAAnC,C,CAEA;AACA;AACA;AACA;;AACA,IAAMC,eAAuC,GAAGd,OAAO,CAACa,sBAAD,CAAvD;AAEA;AACA;AACA;AACA;;AACA,SAASE,QAAT,CAAkBC,QAAlB,EAAwD;AACtD,sBAAO,oCAASA,QAAT,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,UAAT,CAAoBC,YAApB,EAA0CC,IAA1C,EAAsE;AACpE,sBACE,oBAAC,eAAD;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;AAED;AACA;AACA;;;AACA,SAASC,WAAT,CAAqBJ,QAArB,EAA2D;AACzD,sBACE;AACE,IAAA,IAAI,EAAC,gFADP;AAEE,IAAA,GAAG,EAAC,qBAFN;AAGE,IAAA,M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n// @ts-expect-error FIXME: Create TypeScript types for core-utils packages.\nimport coreUtils from \"@opentripplanner/core-utils\";\nimport { FlexBookingInfo } from \"@opentripplanner/types\";\nimport React, { ReactElement } from \"react\";\nimport { FormattedMessage, FormattedNumber } from \"react-intl\";\nimport { CalendarAlt } from \"@styled-icons/fa-solid/CalendarAlt\";\nimport { HandPaper } from \"@styled-icons/fa-solid/HandPaper\";\nimport { Heartbeat } from \"@styled-icons/fa-solid/Heartbeat\";\nimport { MoneyBillAlt } from \"@styled-icons/fa-solid/MoneyBillAlt\";\nimport { PhoneVolume } from \"@styled-icons/fa-solid/PhoneVolume\";\nimport { Route } from \"@styled-icons/fa-solid/Route\";\n\nimport * as S from \"./styled\";\nimport TripDetail from \"./trip-detail\";\n\nimport {\n CaloriesDetailsProps,\n TransitFareProps,\n TripDetailsProps\n} 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\n/**\n * Format text bold (used with FormattedMessage).\n */\n// TODO: Find a better place for this utility.\nfunction boldText(contents: ReactElement): 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 */\nfunction 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\n/**\n * Helper function to specify the link to dietary table.\n */\nfunction dietaryLink(contents: ReactElement): ReactElement {\n return (\n <a\n href=\"https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {contents}\n </a>\n );\n}\n\n/**\n * Helper function that assembles values for flex pickup/dropoff messages.\n */\nfunction getFlexMessageValues(info: FlexBookingInfo) {\n return {\n hasLeadTime: coreUtils.itinerary.isAdvanceBookingRequired(info),\n hasPhone: !!info?.contactInfo?.phoneNumber,\n leadDays: info.latestBookingTime.daysPrior,\n phoneNumber: info?.contactInfo?.phoneNumber\n };\n}\n\n/**\n * Default rendering if no component is provided for the CaloriesDetails\n * slot in the TripDetails component.\n */\nfunction DefaultCaloriesDetails({\n bikeSeconds,\n calories,\n walkSeconds\n}: CaloriesDetailsProps): ReactElement {\n return (\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.caloriesDescription\"]}\n description=\"Text describing how the calories relate to the walking and biking duration of a trip.\"\n id=\"otpUi.TripDetails.caloriesDescription\"\n values={{\n bikeMinutes: Math.round(bikeSeconds / 60),\n calories: Math.round(calories),\n dietaryLink,\n strong: boldText,\n walkMinutes: Math.round(walkSeconds / 60)\n }}\n />\n );\n}\n\n/**\n * Helper component that renders a transit fare entry.\n */\nconst TransitFare = ({\n fareKey,\n fareNameFallback,\n fareKeyNameMap,\n transitFares\n}: TransitFareProps): ReactElement => {\n const currentFare = transitFares[fareKey];\n\n return (\n <span>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.transitFareEntry\"]}\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFareEntry\"\n values={{\n name: fareKeyNameMap[fareKey] || fareNameFallback || fareKey,\n strong: boldText,\n value: renderFare(\n currentFare.currencyCode,\n currentFare.transitFare / 100\n )\n }}\n />\n </span>\n );\n};\n\n/**\n * Renders trip details such as departure instructions, fare amount, and calories spent.\n */\nexport function TripDetails({\n CaloriesDetails = DefaultCaloriesDetails,\n className = \"\",\n DepartureDetails = null,\n defaultFareKey = \"regular\",\n FareDetails = null,\n fareKeyNameMap = {},\n itinerary\n}: TripDetailsProps): ReactElement {\n // process the transit fare\n const fareResult = coreUtils.itinerary.calculateFares(itinerary, true);\n const { maxTNCFare, minTNCFare, tncCurrencyCode, transitFares } = fareResult;\n\n let defaultFare = defaultFareKey;\n if (!transitFares[defaultFareKey]) {\n defaultFare = \"regular\";\n }\n\n let companies = \"\";\n itinerary.legs.forEach(leg => {\n if (leg.tncData) {\n companies = leg.tncData.company;\n }\n });\n let fare;\n\n const fareKeys = transitFares && Object.keys(transitFares).sort();\n\n if (transitFares && fareKeys.length > 0) {\n // Depending on if there are additional fares to display either render a <span> or a <details>\n const TransitFareWrapper =\n transitFares && fareKeys.length > 1 ? S.TransitFare : S.TransitFareSingle;\n\n fare = (\n <S.Fare>\n <TransitFareWrapper>\n <summary style={{ display: fareKeys.length > 1 ? \"list-item\" : \"\" }}>\n <TransitFare\n fareNameFallback={\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.transitFare\"]\n }\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFare\"\n />\n }\n fareKey={defaultFare}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n </summary>\n {fareKeys.map(fareKey => {\n // Don't show the default fare twice!\n if (fareKey === defaultFare) {\n return null;\n }\n return (\n <TransitFare\n fareKey={fareKey}\n key={fareKey}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n );\n })}\n </TransitFareWrapper>\n {minTNCFare !== 0 && (\n <S.TNCFare>\n <br />\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>\n {companies.toLowerCase()}\n </S.TNCFareCompanies>\n ),\n maxTNCFare: renderFare(tncCurrencyCode, maxTNCFare),\n minTNCFare: renderFare(tncCurrencyCode, minTNCFare),\n strong: boldText\n }}\n />\n </S.TNCFare>\n )}\n </S.Fare>\n );\n }\n\n const departureDate = new Date(itinerary.startTime);\n\n // Compute calories burned.\n const {\n bikeDuration,\n caloriesBurned,\n walkDuration\n } = coreUtils.itinerary.calculatePhysicalActivity(itinerary);\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\n return (\n <S.TripDetails className={className}>\n <S.TripDetailsHeader>\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 transitFares={transitFares}\n />\n )\n }\n icon={<MoneyBillAlt size={17} />}\n summary={fare}\n />\n )}\n {caloriesBurned > 0 && (\n <TripDetail\n icon={<Heartbeat size={17} />}\n summary={\n <S.CaloriesSummary>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.calories\"]}\n description=\"Text showing the number of calories for the walking and biking legs of a trip.\"\n id=\"otpUi.TripDetails.calories\"\n values={{\n calories: caloriesBurned,\n strong: boldText\n }}\n />\n </S.CaloriesSummary>\n }\n description={\n CaloriesDetails && (\n <CaloriesDetails\n bikeSeconds={bikeDuration}\n calories={caloriesBurned}\n walkSeconds={walkDuration}\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 />\n </S.FlexSummary>\n }\n icon={<Route size={17} />}\n />\n )}\n {pickupBookingInfo &&\n pickupBookingInfo.map(info => (\n <TripDetail\n key={info.pickupMessage}\n icon={<PhoneVolume size={17} />}\n summary={\n <S.FlexPickupSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.flexPickupMessage\"]\n }\n description=\"Instructions for booking and boarding the flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.flexPickupMessage\"\n values={getFlexMessageValues(info)}\n />\n </S.FlexPickupSummary>\n }\n description={info.pickupMessage}\n />\n ))}\n {dropOffBookingInfo &&\n dropOffBookingInfo.map(info => (\n <TripDetail\n description={info.dropOffMessage}\n icon={\n coreUtils.itinerary.isAdvanceBookingRequired(info) ? (\n <PhoneVolume size={17} />\n ) : (\n <HandPaper size={17} />\n )\n }\n key={info.dropOffMessage}\n summary={\n <S.FlexDropOffSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.flexDropOffMessage\"]\n }\n description=\"Instructions for getting off the flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.flexDropOffMessage\"\n values={getFlexMessageValues(info)}\n />\n </S.FlexDropOffSummary>\n }\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 };\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.tsx"],"names":["flatten","coreUtils","React","FormattedMessage","FormattedNumber","CalendarAlt","HandPaper","Heartbeat","MoneyBillAlt","PhoneVolume","Route","S","TripDetail","defaultEnglishMessages","defaultMessages","boldText","contents","renderFare","currencyCode","fare","dietaryLink","getFlexMessageValues","info","hasLeadTime","itinerary","isAdvanceBookingRequired","hasPhone","contactInfo","phoneNumber","leadDays","latestBookingTime","daysPrior","DefaultCaloriesDetails","bikeSeconds","calories","walkSeconds","bikeMinutes","Math","round","strong","walkMinutes","TransitFare","fareKey","fareNameFallback","fareKeyNameMap","transitFares","currentFare","name","value","currency","cents","TripDetails","CaloriesDetails","className","DepartureDetails","defaultFareKey","FareDetails","fareResult","calculateTncFares","maxTNCFare","minTNCFare","tncCurrencyCode","companies","legs","forEach","leg","tncData","company","fareKeys","Object","keys","sort","length","defaultFare","TransitFareWrapper","TransitFareSingle","display","map","toLowerCase","departureDate","Date","startTime","calculatePhysicalActivity","bikeDuration","caloriesBurned","walkDuration","containsFlex","some","isFlex","pickupBookingInfo","filter","dropOffBookingInfo","pickupMessage","dropOffMessage","Styled"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,MAApB,C,CACA;AACA;;AACA,OAAOC,SAAP,MAAsB,6BAAtB;AAEA,OAAOC,KAAP,MAAoC,OAApC;AACA,SAASC,gBAAT,EAA2BC,eAA3B,QAAkD,YAAlD;AACA,SAASC,WAAT,QAA4B,oCAA5B;AACA,SAASC,SAAT,QAA0B,kCAA1B;AACA,SAASC,SAAT,QAA0B,kCAA1B;AACA,SAASC,YAAT,QAA6B,qCAA7B;AACA,SAASC,WAAT,QAA4B,oCAA5B;AACA,SAASC,KAAT,QAAsB,8BAAtB;AAEA,OAAO,KAAKC,CAAZ,MAAmB,UAAnB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AAQA;AACA,OAAOC,sBAAP,MAAmC,mBA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oBAAC,UAAD;AACE,MAAA,WAAW,EAAEA,IAAI,CAACuE,cADpB;AAEE,MAAA,IAAI,EACF5F,SAAS,CAACuB,SAAV,CAAoBC,wBAApB,CAA6CH,IAA7C,iBACE,oBAAC,WAAD;AAAa,QAAA,IAAI,EAAE;AAAnB,QADF,gBAGE,oBAAC,SAAD;AAAW,QAAA,IAAI,EAAE;AAAjB,QANN;AASE,MAAA,GAAG,EAAEA,IAAI,CAACuE,cATZ;AAUE,MAAA,OAAO,eACL,oBAAC,CAAD,CAAG,kBAAH,qBACE,oBAAC,gBAAD;AACE,QAAA,cAAc,EACZ/E,eAAe,CAAC,sCAAD,CAFnB;AAIE,QAAA,WAAW,EAAC,oEAJd;AAKE,QAAA,EAAE,EAAC,sCALL;AAME,QAAA,MAAM,EAAEO,oBAAoB,CAACC,IAAD;AAN9B,QADF;AAXJ,MADyB;AAAA,GAA3B,CAvGJ,CARF,CADF;AA4ID;AAED,eAAe6B,WAAf,C,CAEA;;AACA,SAASxC,CAAC,IAAImF,MAAd","sourcesContent":["import flatten from \"flat\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore FIXME: Create TypeScript types for core-utils packages.\nimport coreUtils from \"@opentripplanner/core-utils\";\nimport { FlexBookingInfo } from \"@opentripplanner/types\";\nimport React, { ReactElement } from \"react\";\nimport { FormattedMessage, FormattedNumber } from \"react-intl\";\nimport { CalendarAlt } from \"@styled-icons/fa-solid/CalendarAlt\";\nimport { HandPaper } from \"@styled-icons/fa-solid/HandPaper\";\nimport { Heartbeat } from \"@styled-icons/fa-solid/Heartbeat\";\nimport { MoneyBillAlt } from \"@styled-icons/fa-solid/MoneyBillAlt\";\nimport { PhoneVolume } from \"@styled-icons/fa-solid/PhoneVolume\";\nimport { Route } from \"@styled-icons/fa-solid/Route\";\n\nimport * as S from \"./styled\";\nimport TripDetail from \"./trip-detail\";\n\nimport {\n CaloriesDetailsProps,\n TransitFareProps,\n TripDetailsProps\n} 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\n/**\n * Format text bold (used with FormattedMessage).\n */\n// TODO: Find a better place for this utility.\nfunction boldText(contents: ReactElement): 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 */\nfunction 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\n/**\n * Helper function to specify the link to dietary table.\n */\nfunction dietaryLink(contents: ReactElement): ReactElement {\n return (\n <a\n href=\"https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {contents}\n </a>\n );\n}\n\n/**\n * Helper function that assembles values for flex pickup/dropoff messages.\n */\nfunction getFlexMessageValues(info: FlexBookingInfo) {\n return {\n hasLeadTime: coreUtils.itinerary.isAdvanceBookingRequired(info),\n hasPhone: !!info?.contactInfo?.phoneNumber,\n leadDays: info.latestBookingTime.daysPrior,\n phoneNumber: info?.contactInfo?.phoneNumber\n };\n}\n\n/**\n * Default rendering if no component is provided for the CaloriesDetails\n * slot in the TripDetails component.\n */\nfunction DefaultCaloriesDetails({\n bikeSeconds,\n calories,\n walkSeconds\n}: CaloriesDetailsProps): ReactElement {\n return (\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.caloriesDescription\"]}\n description=\"Text describing how the calories relate to the walking and biking duration of a trip.\"\n id=\"otpUi.TripDetails.caloriesDescription\"\n values={{\n bikeMinutes: Math.round(bikeSeconds / 60),\n calories: Math.round(calories),\n dietaryLink,\n strong: boldText,\n walkMinutes: Math.round(walkSeconds / 60)\n }}\n />\n );\n}\n\n/**\n * Helper component that renders a transit fare entry.\n */\nconst TransitFare = ({\n fareKey,\n fareNameFallback,\n fareKeyNameMap,\n transitFares\n}: TransitFareProps): ReactElement => {\n const currentFare = transitFares[fareKey];\n\n return (\n <span>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.transitFareEntry\"]}\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFareEntry\"\n values={{\n name: fareKeyNameMap[fareKey] || fareNameFallback || fareKey,\n strong: boldText,\n value: renderFare(\n currentFare.currency.currencyCode,\n currentFare.cents / 100\n )\n }}\n />\n </span>\n );\n};\n\n/**\n * Renders trip details such as departure instructions, fare amount, and calories spent.\n */\nexport function TripDetails({\n CaloriesDetails = DefaultCaloriesDetails,\n className = \"\",\n DepartureDetails = null,\n defaultFareKey = \"regular\",\n FareDetails = null,\n fareKeyNameMap = {},\n itinerary\n}: TripDetailsProps): ReactElement {\n // process the transit fare\n const fareResult = coreUtils.itinerary.calculateTncFares(itinerary);\n const { maxTNCFare, minTNCFare, tncCurrencyCode } = fareResult;\n const transitFares = itinerary?.fare?.fare;\n\n let companies = \"\";\n itinerary.legs.forEach(leg => {\n if (leg.tncData) {\n companies = leg.tncData.company;\n }\n });\n let fare;\n\n const fareKeys = transitFares && Object.keys(transitFares).sort();\n\n if (transitFares && fareKeys.length > 0) {\n let defaultFare = defaultFareKey;\n if (!transitFares[defaultFareKey]) {\n defaultFare = \"regular\";\n }\n\n // Depending on if there are additional fares to display either render a <span> or a <details>\n const TransitFareWrapper =\n transitFares && fareKeys.length > 1 ? S.TransitFare : S.TransitFareSingle;\n\n fare = (\n <S.Fare>\n <TransitFareWrapper>\n <summary style={{ display: fareKeys.length > 1 ? \"list-item\" : \"\" }}>\n <TransitFare\n fareNameFallback={\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.transitFare\"]\n }\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFare\"\n />\n }\n fareKey={defaultFare}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n </summary>\n {fareKeys.map(fareKey => {\n // Don't show the default fare twice!\n if (fareKey === defaultFare) {\n return null;\n }\n return (\n <TransitFare\n fareKey={fareKey}\n key={fareKey}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n );\n })}\n </TransitFareWrapper>\n {minTNCFare !== 0 && (\n <S.TNCFare>\n <br />\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>\n {companies.toLowerCase()}\n </S.TNCFareCompanies>\n ),\n maxTNCFare: renderFare(tncCurrencyCode, maxTNCFare),\n minTNCFare: renderFare(tncCurrencyCode, minTNCFare),\n strong: boldText\n }}\n />\n </S.TNCFare>\n )}\n </S.Fare>\n );\n }\n\n const departureDate = new Date(itinerary.startTime);\n\n // Compute calories burned.\n const {\n bikeDuration,\n caloriesBurned,\n walkDuration\n } = coreUtils.itinerary.calculatePhysicalActivity(itinerary);\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\n return (\n <S.TripDetails className={className}>\n <S.TripDetailsHeader>\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 transitFares={transitFares}\n />\n )\n }\n icon={<MoneyBillAlt size={17} />}\n summary={fare}\n />\n )}\n {caloriesBurned > 0 && (\n <TripDetail\n icon={<Heartbeat size={17} />}\n summary={\n <S.CaloriesSummary>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.calories\"]}\n description=\"Text showing the number of calories for the walking and biking legs of a trip.\"\n id=\"otpUi.TripDetails.calories\"\n values={{\n calories: caloriesBurned,\n strong: boldText\n }}\n />\n </S.CaloriesSummary>\n }\n description={\n CaloriesDetails && (\n <CaloriesDetails\n bikeSeconds={bikeDuration}\n calories={caloriesBurned}\n walkSeconds={walkDuration}\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 />\n </S.FlexSummary>\n }\n icon={<Route size={17} />}\n />\n )}\n {pickupBookingInfo &&\n pickupBookingInfo.map(info => (\n <TripDetail\n key={info.pickupMessage}\n icon={<PhoneVolume size={17} />}\n summary={\n <S.FlexPickupSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.flexPickupMessage\"]\n }\n description=\"Instructions for booking and boarding the flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.flexPickupMessage\"\n values={getFlexMessageValues(info)}\n />\n </S.FlexPickupSummary>\n }\n description={info.pickupMessage}\n />\n ))}\n {dropOffBookingInfo &&\n dropOffBookingInfo.map(info => (\n <TripDetail\n description={info.dropOffMessage}\n icon={\n coreUtils.itinerary.isAdvanceBookingRequired(info) ? (\n <PhoneVolume size={17} />\n ) : (\n <HandPaper size={17} />\n )\n }\n key={info.dropOffMessage}\n summary={\n <S.FlexDropOffSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.flexDropOffMessage\"]\n }\n description=\"Instructions for getting off the flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.flexDropOffMessage\"\n values={getFlexMessageValues(info)}\n />\n </S.FlexDropOffSummary>\n }\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 };\n"],"file":"index.js"}
package/i18n/en-US.yml CHANGED
@@ -14,11 +14,12 @@
14
14
  otpUi:
15
15
  TripDetails:
16
16
  calories: "Calories Burned: <strong>{calories, number, ::.}</strong>"
17
- caloriesDescription: "Calories burned is based on
17
+ caloriesDescription: >
18
+ Calories burned is based on
18
19
  <strong>{walkMinutes, plural, one {# minute} other {# minutes}}</strong> spent walking and
19
20
  <strong>{bikeMinutes, plural, one {# minute} other {# minutes}}</strong> spent biking during this trip.
20
- Adapted from <dietaryLink>Dietary Guidelines for Americans 2005, page 16, Table 4</dietaryLink>."
21
- departure: "Depart <strong>{departureDate, date, long}</strong> at <strong>{departureDate, time, short}</strong>"
21
+ Adapted from <dietaryLink>Dietary Guidelines for Americans 2005, page 16, Table 4</dietaryLink>.
22
+ departure: Depart <strong>{departureDate, date, long}</strong> at <strong>{departureDate, time, short}</strong>
22
23
  flexDropOffMessage: >
23
24
  {hasLeadTime, select,
24
25
  true {To get off at your destination, you must call
@@ -36,8 +37,8 @@ otpUi:
36
37
  true { at least {leadDays, plural, one {# day} other {# days}} in advance}
37
38
  other {}
38
39
  }.
39
- title: "Trip Details"
40
+ title: Trip Details
40
41
  tncFare: "{companies} Fare: <strong>{minTNCFare} - {maxTNCFare}</strong>"
41
- transitFare: "Transit Fare"
42
+ transitFare: Transit Fare
42
43
  transitFareEntry: "{name}: <strong>{value}</strong>"
43
44
  tripIncludesFlex: This trip includes flexible routes.
package/i18n/fr.yml CHANGED
@@ -2,11 +2,12 @@
2
2
  otpUi:
3
3
  TripDetails:
4
4
  calories: "Calories dépensées : <strong>{calories, number, ::.}</strong>"
5
- caloriesDescription: "La dépense calorique est calculée sur la base de
5
+ caloriesDescription: >
6
+ La dépense calorique est calculée sur la base de
6
7
  {walkMinutes, plural, one {<strong># minute</strong> effectuée} other {<strong># minutes</strong> effectuées}} à pied et
7
8
  {bikeMinutes, plural, one {<strong># minute</strong> effectuée} other {<strong># minutes</strong> effectuées}} en vélo sur ce trajet.
8
- (d'après <dietaryLink>Dietary Guidelines for Americans 2005, page 16, Table 4</dietaryLink>)"
9
- departure: "Départ le <strong>{departureDate, date, long}</strong> à <strong>{departureDate, time, short}</strong>"
9
+ (d'après <dietaryLink>Dietary Guidelines for Americans 2005, page 16, Table 4</dietaryLink>)
10
+ departure: Départ le <strong>{departureDate, date, long}</strong> à <strong>{departureDate, time, short}</strong>
10
11
  flexDropOffMessage: >
11
12
  {hasLeadTime, select,
12
13
  true {Pour descendre à votre destination, vous devez faire une réservation préalable
@@ -24,8 +25,8 @@ otpUi:
24
25
  true { au moins {leadDays, plural, one {# jour} other {# jours}} à l'avance}
25
26
  other {}
26
27
  }.
27
- title: "Détails du trajet"
28
+ title: Détails du trajet
28
29
  tncFare: "Tarif {companies} : <strong>{minTNCFare} - {maxTNCFare}</strong>"
29
- transitFare: "Tarif en transports"
30
+ transitFare: Tarif en transports
30
31
  transitFareEntry: "{name} : <strong>{value}</strong>"
31
32
  tripIncludesFlex: Ce trajet comprend un service à la demande (Flex).
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAS5C,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,EAGL,gBAAgB,EACjB,MAAM,SAAS,CAAC;AA0HjB;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAC1B,eAAwC,EACxC,SAAc,EACd,gBAAuB,EACvB,cAA0B,EAC1B,WAAkB,EAClB,cAAmB,EACnB,SAAS,EACV,EAAE,gBAAgB,GAAG,YAAY,CAmPjC;AAED,eAAe,WAAW,CAAC;AAG3B,OAAO,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAKA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAS5C,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,EAGL,gBAAgB,EACjB,MAAM,SAAS,CAAC;AA0HjB;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAC1B,eAAwC,EACxC,SAAc,EACd,gBAAuB,EACvB,cAA0B,EAC1B,WAAkB,EAClB,cAAmB,EACnB,SAAS,EACV,EAAE,gBAAgB,GAAG,YAAY,CAoPjC;AAED,eAAe,WAAW,CAAC;AAG3B,OAAO,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC"}
package/lib/index.js CHANGED
@@ -40,7 +40,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
40
40
 
41
41
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
42
42
 
43
- // @ts-expect-error FIXME: Create TypeScript types for core-utils packages.
43
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
44
+ // @ts-ignore FIXME: Create TypeScript types for core-utils packages.
44
45
  // Load the default messages.
45
46
  // HACK: We should flatten the messages loaded above because
46
47
  // the YAML loaders behave differently between webpack and our version of jest:
@@ -145,7 +146,7 @@ const TransitFare = ({
145
146
  values: {
146
147
  name: fareKeyNameMap[fareKey] || fareNameFallback || fareKey,
147
148
  strong: boldText,
148
- value: renderFare(currentFare.currencyCode, currentFare.transitFare / 100)
149
+ value: renderFare(currentFare.currency.currencyCode, currentFare.cents / 100)
149
150
  }
150
151
  }));
151
152
  };
@@ -163,21 +164,17 @@ function TripDetails({
163
164
  fareKeyNameMap = {},
164
165
  itinerary
165
166
  }) {
167
+ var _itinerary$fare;
168
+
166
169
  // process the transit fare
167
- const fareResult = _coreUtils.default.itinerary.calculateFares(itinerary, true);
170
+ const fareResult = _coreUtils.default.itinerary.calculateTncFares(itinerary);
168
171
 
169
172
  const {
170
173
  maxTNCFare,
171
174
  minTNCFare,
172
- tncCurrencyCode,
173
- transitFares
175
+ tncCurrencyCode
174
176
  } = fareResult;
175
- let defaultFare = defaultFareKey;
176
-
177
- if (!transitFares[defaultFareKey]) {
178
- defaultFare = "regular";
179
- }
180
-
177
+ const transitFares = itinerary === null || itinerary === void 0 ? void 0 : (_itinerary$fare = itinerary.fare) === null || _itinerary$fare === void 0 ? void 0 : _itinerary$fare.fare;
181
178
  let companies = "";
182
179
  itinerary.legs.forEach(leg => {
183
180
  if (leg.tncData) {
@@ -188,7 +185,13 @@ function TripDetails({
188
185
  const fareKeys = transitFares && Object.keys(transitFares).sort();
189
186
 
190
187
  if (transitFares && fareKeys.length > 0) {
191
- // Depending on if there are additional fares to display either render a <span> or a <details>
188
+ let defaultFare = defaultFareKey;
189
+
190
+ if (!transitFares[defaultFareKey]) {
191
+ defaultFare = "regular";
192
+ } // Depending on if there are additional fares to display either render a <span> or a <details>
193
+
194
+
192
195
  const TransitFareWrapper = transitFares && fareKeys.length > 1 ? S.TransitFare : S.TransitFareSingle;
193
196
  fare = /*#__PURE__*/_react.default.createElement(S.Fare, null, /*#__PURE__*/_react.default.createElement(TransitFareWrapper, null, /*#__PURE__*/_react.default.createElement("summary", {
194
197
  style: {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.tsx"],"names":["defaultMessages","defaultEnglishMessages","boldText","contents","renderFare","currencyCode","fare","dietaryLink","getFlexMessageValues","info","hasLeadTime","coreUtils","itinerary","isAdvanceBookingRequired","hasPhone","contactInfo","phoneNumber","leadDays","latestBookingTime","daysPrior","DefaultCaloriesDetails","bikeSeconds","calories","walkSeconds","bikeMinutes","Math","round","strong","walkMinutes","TransitFare","fareKey","fareNameFallback","fareKeyNameMap","transitFares","currentFare","name","value","transitFare","TripDetails","CaloriesDetails","className","DepartureDetails","defaultFareKey","FareDetails","fareResult","calculateFares","maxTNCFare","minTNCFare","tncCurrencyCode","defaultFare","companies","legs","forEach","leg","tncData","company","fareKeys","Object","keys","sort","length","TransitFareWrapper","S","TransitFareSingle","display","map","toLowerCase","departureDate","Date","startTime","bikeDuration","caloriesBurned","walkDuration","calculatePhysicalActivity","containsFlex","some","isFlex","pickupBookingInfo","filter","dropOffBookingInfo","pickupMessage","dropOffMessage"],"mappings":";;;;;;;;;;AAAA;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9B,MADF;AAXJ,IADF,CAvGJ,CARF,CADF;AA4ID;;eAEc6B,W,EAEf","sourcesContent":["import flatten from \"flat\";\n// @ts-expect-error FIXME: Create TypeScript types for core-utils packages.\nimport coreUtils from \"@opentripplanner/core-utils\";\nimport { FlexBookingInfo } from \"@opentripplanner/types\";\nimport React, { ReactElement } from \"react\";\nimport { FormattedMessage, FormattedNumber } from \"react-intl\";\nimport { CalendarAlt } from \"@styled-icons/fa-solid/CalendarAlt\";\nimport { HandPaper } from \"@styled-icons/fa-solid/HandPaper\";\nimport { Heartbeat } from \"@styled-icons/fa-solid/Heartbeat\";\nimport { MoneyBillAlt } from \"@styled-icons/fa-solid/MoneyBillAlt\";\nimport { PhoneVolume } from \"@styled-icons/fa-solid/PhoneVolume\";\nimport { Route } from \"@styled-icons/fa-solid/Route\";\n\nimport * as S from \"./styled\";\nimport TripDetail from \"./trip-detail\";\n\nimport {\n CaloriesDetailsProps,\n TransitFareProps,\n TripDetailsProps\n} 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\n/**\n * Format text bold (used with FormattedMessage).\n */\n// TODO: Find a better place for this utility.\nfunction boldText(contents: ReactElement): 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 */\nfunction 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\n/**\n * Helper function to specify the link to dietary table.\n */\nfunction dietaryLink(contents: ReactElement): ReactElement {\n return (\n <a\n href=\"https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {contents}\n </a>\n );\n}\n\n/**\n * Helper function that assembles values for flex pickup/dropoff messages.\n */\nfunction getFlexMessageValues(info: FlexBookingInfo) {\n return {\n hasLeadTime: coreUtils.itinerary.isAdvanceBookingRequired(info),\n hasPhone: !!info?.contactInfo?.phoneNumber,\n leadDays: info.latestBookingTime.daysPrior,\n phoneNumber: info?.contactInfo?.phoneNumber\n };\n}\n\n/**\n * Default rendering if no component is provided for the CaloriesDetails\n * slot in the TripDetails component.\n */\nfunction DefaultCaloriesDetails({\n bikeSeconds,\n calories,\n walkSeconds\n}: CaloriesDetailsProps): ReactElement {\n return (\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.caloriesDescription\"]}\n description=\"Text describing how the calories relate to the walking and biking duration of a trip.\"\n id=\"otpUi.TripDetails.caloriesDescription\"\n values={{\n bikeMinutes: Math.round(bikeSeconds / 60),\n calories: Math.round(calories),\n dietaryLink,\n strong: boldText,\n walkMinutes: Math.round(walkSeconds / 60)\n }}\n />\n );\n}\n\n/**\n * Helper component that renders a transit fare entry.\n */\nconst TransitFare = ({\n fareKey,\n fareNameFallback,\n fareKeyNameMap,\n transitFares\n}: TransitFareProps): ReactElement => {\n const currentFare = transitFares[fareKey];\n\n return (\n <span>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.transitFareEntry\"]}\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFareEntry\"\n values={{\n name: fareKeyNameMap[fareKey] || fareNameFallback || fareKey,\n strong: boldText,\n value: renderFare(\n currentFare.currencyCode,\n currentFare.transitFare / 100\n )\n }}\n />\n </span>\n );\n};\n\n/**\n * Renders trip details such as departure instructions, fare amount, and calories spent.\n */\nexport function TripDetails({\n CaloriesDetails = DefaultCaloriesDetails,\n className = \"\",\n DepartureDetails = null,\n defaultFareKey = \"regular\",\n FareDetails = null,\n fareKeyNameMap = {},\n itinerary\n}: TripDetailsProps): ReactElement {\n // process the transit fare\n const fareResult = coreUtils.itinerary.calculateFares(itinerary, true);\n const { maxTNCFare, minTNCFare, tncCurrencyCode, transitFares } = fareResult;\n\n let defaultFare = defaultFareKey;\n if (!transitFares[defaultFareKey]) {\n defaultFare = \"regular\";\n }\n\n let companies = \"\";\n itinerary.legs.forEach(leg => {\n if (leg.tncData) {\n companies = leg.tncData.company;\n }\n });\n let fare;\n\n const fareKeys = transitFares && Object.keys(transitFares).sort();\n\n if (transitFares && fareKeys.length > 0) {\n // Depending on if there are additional fares to display either render a <span> or a <details>\n const TransitFareWrapper =\n transitFares && fareKeys.length > 1 ? S.TransitFare : S.TransitFareSingle;\n\n fare = (\n <S.Fare>\n <TransitFareWrapper>\n <summary style={{ display: fareKeys.length > 1 ? \"list-item\" : \"\" }}>\n <TransitFare\n fareNameFallback={\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.transitFare\"]\n }\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFare\"\n />\n }\n fareKey={defaultFare}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n </summary>\n {fareKeys.map(fareKey => {\n // Don't show the default fare twice!\n if (fareKey === defaultFare) {\n return null;\n }\n return (\n <TransitFare\n fareKey={fareKey}\n key={fareKey}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n );\n })}\n </TransitFareWrapper>\n {minTNCFare !== 0 && (\n <S.TNCFare>\n <br />\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>\n {companies.toLowerCase()}\n </S.TNCFareCompanies>\n ),\n maxTNCFare: renderFare(tncCurrencyCode, maxTNCFare),\n minTNCFare: renderFare(tncCurrencyCode, minTNCFare),\n strong: boldText\n }}\n />\n </S.TNCFare>\n )}\n </S.Fare>\n );\n }\n\n const departureDate = new Date(itinerary.startTime);\n\n // Compute calories burned.\n const {\n bikeDuration,\n caloriesBurned,\n walkDuration\n } = coreUtils.itinerary.calculatePhysicalActivity(itinerary);\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\n return (\n <S.TripDetails className={className}>\n <S.TripDetailsHeader>\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 transitFares={transitFares}\n />\n )\n }\n icon={<MoneyBillAlt size={17} />}\n summary={fare}\n />\n )}\n {caloriesBurned > 0 && (\n <TripDetail\n icon={<Heartbeat size={17} />}\n summary={\n <S.CaloriesSummary>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.calories\"]}\n description=\"Text showing the number of calories for the walking and biking legs of a trip.\"\n id=\"otpUi.TripDetails.calories\"\n values={{\n calories: caloriesBurned,\n strong: boldText\n }}\n />\n </S.CaloriesSummary>\n }\n description={\n CaloriesDetails && (\n <CaloriesDetails\n bikeSeconds={bikeDuration}\n calories={caloriesBurned}\n walkSeconds={walkDuration}\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 />\n </S.FlexSummary>\n }\n icon={<Route size={17} />}\n />\n )}\n {pickupBookingInfo &&\n pickupBookingInfo.map(info => (\n <TripDetail\n key={info.pickupMessage}\n icon={<PhoneVolume size={17} />}\n summary={\n <S.FlexPickupSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.flexPickupMessage\"]\n }\n description=\"Instructions for booking and boarding the flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.flexPickupMessage\"\n values={getFlexMessageValues(info)}\n />\n </S.FlexPickupSummary>\n }\n description={info.pickupMessage}\n />\n ))}\n {dropOffBookingInfo &&\n dropOffBookingInfo.map(info => (\n <TripDetail\n description={info.dropOffMessage}\n icon={\n coreUtils.itinerary.isAdvanceBookingRequired(info) ? (\n <PhoneVolume size={17} />\n ) : (\n <HandPaper size={17} />\n )\n }\n key={info.dropOffMessage}\n summary={\n <S.FlexDropOffSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.flexDropOffMessage\"]\n }\n description=\"Instructions for getting off the flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.flexDropOffMessage\"\n values={getFlexMessageValues(info)}\n />\n </S.FlexDropOffSummary>\n }\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 };\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.tsx"],"names":["defaultMessages","defaultEnglishMessages","boldText","contents","renderFare","currencyCode","fare","dietaryLink","getFlexMessageValues","info","hasLeadTime","coreUtils","itinerary","isAdvanceBookingRequired","hasPhone","contactInfo","phoneNumber","leadDays","latestBookingTime","daysPrior","DefaultCaloriesDetails","bikeSeconds","calories","walkSeconds","bikeMinutes","Math","round","strong","walkMinutes","TransitFare","fareKey","fareNameFallback","fareKeyNameMap","transitFares","currentFare","name","value","currency","cents","TripDetails","CaloriesDetails","className","DepartureDetails","defaultFareKey","FareDetails","fareResult","calculateTncFares","maxTNCFare","minTNCFare","tncCurrencyCode","companies","legs","forEach","leg","tncData","company","fareKeys","Object","keys","sort","length","defaultFare","TransitFareWrapper","S","TransitFareSingle","display","map","toLowerCase","departureDate","Date","startTime","bikeDuration","caloriesBurned","walkDuration","calculatePhysicalActivity","containsFlex","some","isFlex","pickupBookingInfo","filter","dropOffBookingInfo","pickupMessage","dropOffMessage"],"mappings":";;;;;;;;;;AAAA;;AAGA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;AACA;;AASA;;;;;;AAvBA;AACA;AAqBA;AAGA;AACA;AACA;AACA;AACA,MAAMA,eAAuC,GAAG,mBAAQC,aAAR,CAAhD;AAEA;AACA;AACA;AACA;;AACA,SAASC,QAAT,CAAkBC,QAAlB,EAAwD;AACtD,sBAAO,6CAASA,QAAT,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,UAAT,CAAoBC,YAApB,EAA0CC,IAA1C,EAAsE;AACpE,sBACE,6BAAC,0BAAD;AACE,IAAA,QAAQ,EAAED,YADZ,CAEE;AACA;AACA;AAJF;AAKE,IAAA,eAA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IAAA,OAAO,eACL,6BAAC,CAAD,CAAG,iBAAH,qBACE,6BAAC,2BAAD;AACE,MAAA,cAAc,EACZjF,eAAe,CAAC,qCAAD,CAFnB;AAIE,MAAA,WAAW,EAAC,6EAJd;AAKE,MAAA,EAAE,EAAC,qCALL;AAME,MAAA,MAAM,EAAEQ,oBAAoB,CAACC,IAAD;AAN9B,MADF,CAJJ;AAeE,IAAA,WAAW,EAAEA,IAAI,CAACwE;AAfpB,IADF,CAnFJ,EAsGGD,kBAAkB,IACjBA,kBAAkB,CAACd,GAAnB,CAAuBzD,IAAI,iBACzB,6BAAC,mBAAD;AACE,IAAA,WAAW,EAAEA,IAAI,CAACyE,cADpB;AAEE,IAAA,IAAI,EACFvE,mBAAUC,SAAV,CAAoBC,wBAApB,CAA6CJ,IAA7C,iBACE,6BAAC,wBAAD;AAAa,MAAA,IAAI,EAAE;AAAnB,MADF,gBAGE,6BAAC,oBAAD;AAAW,MAAA,IAAI,EAAE;AAAjB,MANN;AASE,IAAA,GAAG,EAAEA,IAAI,CAACyE,cATZ;AAUE,IAAA,OAAO,eACL,6BAAC,CAAD,CAAG,kBAAH,qBACE,6BAAC,2BAAD;AACE,MAAA,cAAc,EACZlF,eAAe,CAAC,sCAAD,CAFnB;AAIE,MAAA,WAAW,EAAC,oEAJd;AAKE,MAAA,EAAE,EAAC,sCALL;AAME,MAAA,MAAM,EAAEQ,oBAAoB,CAACC,IAAD;AAN9B,MADF;AAXJ,IADF,CAvGJ,CARF,CADF;AA4ID;;eAEc8B,W,EAEf","sourcesContent":["import flatten from \"flat\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore FIXME: Create TypeScript types for core-utils packages.\nimport coreUtils from \"@opentripplanner/core-utils\";\nimport { FlexBookingInfo } from \"@opentripplanner/types\";\nimport React, { ReactElement } from \"react\";\nimport { FormattedMessage, FormattedNumber } from \"react-intl\";\nimport { CalendarAlt } from \"@styled-icons/fa-solid/CalendarAlt\";\nimport { HandPaper } from \"@styled-icons/fa-solid/HandPaper\";\nimport { Heartbeat } from \"@styled-icons/fa-solid/Heartbeat\";\nimport { MoneyBillAlt } from \"@styled-icons/fa-solid/MoneyBillAlt\";\nimport { PhoneVolume } from \"@styled-icons/fa-solid/PhoneVolume\";\nimport { Route } from \"@styled-icons/fa-solid/Route\";\n\nimport * as S from \"./styled\";\nimport TripDetail from \"./trip-detail\";\n\nimport {\n CaloriesDetailsProps,\n TransitFareProps,\n TripDetailsProps\n} 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\n/**\n * Format text bold (used with FormattedMessage).\n */\n// TODO: Find a better place for this utility.\nfunction boldText(contents: ReactElement): 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 */\nfunction 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\n/**\n * Helper function to specify the link to dietary table.\n */\nfunction dietaryLink(contents: ReactElement): ReactElement {\n return (\n <a\n href=\"https://health.gov/dietaryguidelines/dga2005/document/html/chapter3.htm#table4\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {contents}\n </a>\n );\n}\n\n/**\n * Helper function that assembles values for flex pickup/dropoff messages.\n */\nfunction getFlexMessageValues(info: FlexBookingInfo) {\n return {\n hasLeadTime: coreUtils.itinerary.isAdvanceBookingRequired(info),\n hasPhone: !!info?.contactInfo?.phoneNumber,\n leadDays: info.latestBookingTime.daysPrior,\n phoneNumber: info?.contactInfo?.phoneNumber\n };\n}\n\n/**\n * Default rendering if no component is provided for the CaloriesDetails\n * slot in the TripDetails component.\n */\nfunction DefaultCaloriesDetails({\n bikeSeconds,\n calories,\n walkSeconds\n}: CaloriesDetailsProps): ReactElement {\n return (\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.caloriesDescription\"]}\n description=\"Text describing how the calories relate to the walking and biking duration of a trip.\"\n id=\"otpUi.TripDetails.caloriesDescription\"\n values={{\n bikeMinutes: Math.round(bikeSeconds / 60),\n calories: Math.round(calories),\n dietaryLink,\n strong: boldText,\n walkMinutes: Math.round(walkSeconds / 60)\n }}\n />\n );\n}\n\n/**\n * Helper component that renders a transit fare entry.\n */\nconst TransitFare = ({\n fareKey,\n fareNameFallback,\n fareKeyNameMap,\n transitFares\n}: TransitFareProps): ReactElement => {\n const currentFare = transitFares[fareKey];\n\n return (\n <span>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.transitFareEntry\"]}\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFareEntry\"\n values={{\n name: fareKeyNameMap[fareKey] || fareNameFallback || fareKey,\n strong: boldText,\n value: renderFare(\n currentFare.currency.currencyCode,\n currentFare.cents / 100\n )\n }}\n />\n </span>\n );\n};\n\n/**\n * Renders trip details such as departure instructions, fare amount, and calories spent.\n */\nexport function TripDetails({\n CaloriesDetails = DefaultCaloriesDetails,\n className = \"\",\n DepartureDetails = null,\n defaultFareKey = \"regular\",\n FareDetails = null,\n fareKeyNameMap = {},\n itinerary\n}: TripDetailsProps): ReactElement {\n // process the transit fare\n const fareResult = coreUtils.itinerary.calculateTncFares(itinerary);\n const { maxTNCFare, minTNCFare, tncCurrencyCode } = fareResult;\n const transitFares = itinerary?.fare?.fare;\n\n let companies = \"\";\n itinerary.legs.forEach(leg => {\n if (leg.tncData) {\n companies = leg.tncData.company;\n }\n });\n let fare;\n\n const fareKeys = transitFares && Object.keys(transitFares).sort();\n\n if (transitFares && fareKeys.length > 0) {\n let defaultFare = defaultFareKey;\n if (!transitFares[defaultFareKey]) {\n defaultFare = \"regular\";\n }\n\n // Depending on if there are additional fares to display either render a <span> or a <details>\n const TransitFareWrapper =\n transitFares && fareKeys.length > 1 ? S.TransitFare : S.TransitFareSingle;\n\n fare = (\n <S.Fare>\n <TransitFareWrapper>\n <summary style={{ display: fareKeys.length > 1 ? \"list-item\" : \"\" }}>\n <TransitFare\n fareNameFallback={\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.transitFare\"]\n }\n description=\"Text showing the price of tickets on public transportation.\"\n id=\"otpUi.TripDetails.transitFare\"\n />\n }\n fareKey={defaultFare}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n </summary>\n {fareKeys.map(fareKey => {\n // Don't show the default fare twice!\n if (fareKey === defaultFare) {\n return null;\n }\n return (\n <TransitFare\n fareKey={fareKey}\n key={fareKey}\n fareKeyNameMap={fareKeyNameMap}\n transitFares={transitFares}\n />\n );\n })}\n </TransitFareWrapper>\n {minTNCFare !== 0 && (\n <S.TNCFare>\n <br />\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>\n {companies.toLowerCase()}\n </S.TNCFareCompanies>\n ),\n maxTNCFare: renderFare(tncCurrencyCode, maxTNCFare),\n minTNCFare: renderFare(tncCurrencyCode, minTNCFare),\n strong: boldText\n }}\n />\n </S.TNCFare>\n )}\n </S.Fare>\n );\n }\n\n const departureDate = new Date(itinerary.startTime);\n\n // Compute calories burned.\n const {\n bikeDuration,\n caloriesBurned,\n walkDuration\n } = coreUtils.itinerary.calculatePhysicalActivity(itinerary);\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\n return (\n <S.TripDetails className={className}>\n <S.TripDetailsHeader>\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 transitFares={transitFares}\n />\n )\n }\n icon={<MoneyBillAlt size={17} />}\n summary={fare}\n />\n )}\n {caloriesBurned > 0 && (\n <TripDetail\n icon={<Heartbeat size={17} />}\n summary={\n <S.CaloriesSummary>\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.calories\"]}\n description=\"Text showing the number of calories for the walking and biking legs of a trip.\"\n id=\"otpUi.TripDetails.calories\"\n values={{\n calories: caloriesBurned,\n strong: boldText\n }}\n />\n </S.CaloriesSummary>\n }\n description={\n CaloriesDetails && (\n <CaloriesDetails\n bikeSeconds={bikeDuration}\n calories={caloriesBurned}\n walkSeconds={walkDuration}\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 />\n </S.FlexSummary>\n }\n icon={<Route size={17} />}\n />\n )}\n {pickupBookingInfo &&\n pickupBookingInfo.map(info => (\n <TripDetail\n key={info.pickupMessage}\n icon={<PhoneVolume size={17} />}\n summary={\n <S.FlexPickupSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.flexPickupMessage\"]\n }\n description=\"Instructions for booking and boarding the flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.flexPickupMessage\"\n values={getFlexMessageValues(info)}\n />\n </S.FlexPickupSummary>\n }\n description={info.pickupMessage}\n />\n ))}\n {dropOffBookingInfo &&\n dropOffBookingInfo.map(info => (\n <TripDetail\n description={info.dropOffMessage}\n icon={\n coreUtils.itinerary.isAdvanceBookingRequired(info) ? (\n <PhoneVolume size={17} />\n ) : (\n <HandPaper size={17} />\n )\n }\n key={info.dropOffMessage}\n summary={\n <S.FlexDropOffSummary>\n <FormattedMessage\n defaultMessage={\n defaultMessages[\"otpUi.TripDetails.flexDropOffMessage\"]\n }\n description=\"Instructions for getting off the flex (on-demand) transit service.\"\n id=\"otpUi.TripDetails.flexDropOffMessage\"\n values={getFlexMessageValues(info)}\n />\n </S.FlexDropOffSummary>\n }\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 };\n"],"file":"index.js"}
package/lib/types.d.ts CHANGED
@@ -10,8 +10,13 @@ export interface DepartureDetailsProps {
10
10
  }
11
11
  export interface TransitFareData {
12
12
  [key: string]: {
13
- currencyCode: string;
14
- transitFare: number;
13
+ currency: {
14
+ currencyCode: string;
15
+ defaultFractionDigits: number;
16
+ currency: string;
17
+ symbol: string;
18
+ };
19
+ cents: number;
15
20
  };
16
21
  }
17
22
  export interface FareDetailsProps {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAA;CACF;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,eAAe,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,YAAY,CAAC;IAChC,cAAc,EAAE;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;IACF,YAAY,EAAE,eAAe,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAC1D;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,qBAAq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IACH,eAAe,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAC1D;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAC5D;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAClD;;OAEG;IACH,cAAc,CAAC,EAAE;QACf,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;KACxB,CAAC;IACF;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;CACtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentripplanner/trip-details",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
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,18 +11,18 @@
11
11
  "license": "MIT",
12
12
  "private": false,
13
13
  "dependencies": {
14
- "@opentripplanner/core-utils": "^4.5.0",
14
+ "@opentripplanner/core-utils": "^4.6.0",
15
15
  "@styled-icons/fa-solid": "^10.34.0",
16
16
  "flat": "^5.0.2",
17
17
  "velocity-react": "^1.4.3"
18
18
  },
19
19
  "devDependencies": {
20
- "@opentripplanner/types": "^1.0.2",
20
+ "@opentripplanner/types": "^1.1.0",
21
21
  "@types/flat": "^5.0.2"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "^16.14.0",
25
- "react-intl": "^5.20.4",
25
+ "react-intl": "^5.24.6",
26
26
  "styled-components": "^5.3.0"
27
27
  },
28
28
  "bugs": {
@@ -1,7 +1,11 @@
1
1
  import flatten from "flat";
2
2
  import React, { ReactElement } from "react";
3
- import { IntlProvider } from "react-intl";
4
- import { Meta, Story as StoryType } from "@storybook/react";
3
+ import {
4
+ ComponentMeta,
5
+ ComponentStory,
6
+ Parameters,
7
+ StoryContext
8
+ } from "@storybook/react";
5
9
  import styled from "styled-components";
6
10
  // The below eslint-disable is due to https://github.com/storybookjs/storybook/issues/13408
7
11
  // eslint-disable-next-line import/no-named-as-default
@@ -14,19 +18,8 @@ import {
14
18
  TripDetailsProps
15
19
  } from "./types";
16
20
 
17
- import englishMessages from "../i18n/en-US.yml";
18
- import frenchMessages from "../i18n/fr.yml";
19
21
  import customMessages from "../__mocks__/custom-messages.yml";
20
22
 
21
- /**
22
- * Describes args passed to stories.
23
- */
24
- interface StoryArgs {
25
- locale?: string;
26
- useCustomMessages?: boolean;
27
- useLocalizedMessages?: boolean;
28
- }
29
-
30
23
  // import mock itinaries. These are all trip plan outputs from OTP.
31
24
  const bikeOnlyItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/bike-only.json");
32
25
  const bikeRentalItinerary = require("@opentripplanner/itinerary-body/src/__mocks__/itineraries/bike-rental.json");
@@ -122,17 +115,20 @@ const CustomCaloriesDetails = ({
122
115
  * @param Component The component to render.
123
116
  */
124
117
  function createTripDetailsTemplate(
125
- Component: React.ElementType<TripDetailsProps> = TripDetails
126
- ) {
127
- const TripDetailsTemplate = ({
128
- CaloriesDetails,
129
- defaultFare,
130
- DepartureDetails,
131
- FareDetails,
132
- itinerary,
133
- locale,
134
- useCustomFareKeyMap
135
- }: TripDetailsProps): ReactElement => {
118
+ Component: typeof TripDetails = TripDetails
119
+ ): ComponentStory<typeof TripDetails> {
120
+ const TripDetailsTemplate = (
121
+ {
122
+ CaloriesDetails,
123
+ defaultFare,
124
+ DepartureDetails,
125
+ FareDetails,
126
+ itinerary
127
+ }: TripDetailsProps,
128
+ { globals, parameters }: StoryContext
129
+ ): ReactElement => {
130
+ const { locale } = globals;
131
+ const { useCustomFareKeyMap } = parameters;
136
132
  const fareKeyNameMap = useCustomFareKeyMap
137
133
  ? locale === "en-US"
138
134
  ? englishFareKeyMap
@@ -152,93 +148,35 @@ function createTripDetailsTemplate(
152
148
  return TripDetailsTemplate;
153
149
  }
154
150
 
155
- const intlDecorator = (
156
- Story: StoryType,
157
- context: {
158
- args: StoryArgs;
159
- }
160
- ): ReactElement => {
161
- const { args } = context;
162
- const { locale, useCustomMessages, useLocalizedMessages } = args;
163
- const messages = locale === "en-US" ? englishMessages : frenchMessages;
164
-
165
- // Construct a messages object that customizes a subset
166
- // of the default messages of the desired locale.
167
- // The structure of the message objects is
168
- // flattened before it is passed to IntlProvider.
169
- // Note: the spread operator (...) is rejected if used with flatten,
170
- // so we use Object.assign instead
171
- // (see e.g. https://github.com/Microsoft/TypeScript/issues/10727#issuecomment-423712256).
172
- let mergedMessages: Record<string, string> = flatten(messages);
173
- if (useCustomMessages) {
174
- mergedMessages = Object.assign(mergedMessages, flatten(customMessages));
175
- }
176
- return (
177
- <IntlProvider
178
- locale={locale}
179
- messages={useLocalizedMessages ? mergedMessages : null}
180
- >
181
- <Story />
182
- </IntlProvider>
183
- );
184
- };
185
-
186
151
  /**
187
152
  * Helper to simplify story declaration.
188
153
  */
189
154
  function makeStory(
190
- args: StoryArgs | TripDetailsProps,
191
- Component?: React.ElementType<TripDetailsProps>
192
- ) {
155
+ args: TripDetailsProps,
156
+ parameters: Parameters,
157
+ Component?: typeof TripDetails
158
+ ): ComponentStory<typeof TripDetails> {
193
159
  const BoundTripDetails = createTripDetailsTemplate(Component).bind({});
194
160
  BoundTripDetails.args = args;
161
+ BoundTripDetails.parameters = parameters;
195
162
  return BoundTripDetails;
196
163
  }
197
164
 
198
- const decoratorPropDescription = "(This prop is used by the decorator.)";
199
- // Hide story controls for some props.
200
- const noControl = {
201
- control: { type: false }
202
- };
203
- // Hide some story args completely.
204
- const hiddenProp = {
205
- table: { disable: true }
206
- };
207
-
208
165
  export default {
209
- argTypes: {
210
- CaloriesDetails: noControl,
211
- className: noControl,
212
- Component: hiddenProp,
213
- defaultFareKey: noControl,
214
- DepartureDetails: noControl,
215
- FareDetails: noControl,
216
- fareKeyNameMap: noControl,
217
- itinerary: noControl,
218
- locale: {
219
- control: "radio",
220
- description: decoratorPropDescription,
221
- options: ["en-US", "fr"]
222
- },
223
- useCustomFareKeyMap: hiddenProp,
224
- useCustomMessages: {
225
- description: decoratorPropDescription
226
- },
227
- useLocalizedMessages: {
228
- description: decoratorPropDescription
229
- }
230
- },
231
166
  args: {
232
- defaultFareKey: "regular",
233
- locale: "en-US",
234
- useCustomMessages: false,
235
- useLocalizedMessages: true
167
+ defaultFareKey: "regular"
236
168
  },
237
169
  component: TripDetails,
238
- decorators: [intlDecorator],
239
- parameters: { controls: { sort: "alpha" } },
170
+ parameters: {
171
+ // Hide all controls
172
+ // (there are no args that the user can interactively change for this component).
173
+ controls: {
174
+ hideNoControlsWarning: true,
175
+ include: []
176
+ }
177
+ },
240
178
  title: "TripDetails"
241
- } as Meta;
179
+ } as ComponentMeta<typeof TripDetails>;
242
180
 
243
181
  export const WalkOnlyItinerary = makeStory({
244
182
  itinerary: walkOnlyItinerary
@@ -256,6 +194,7 @@ export const StyledWalkTransitWalkItinerary = makeStory(
256
194
  {
257
195
  itinerary: walkTransitWalkItinerary
258
196
  },
197
+ null,
259
198
  StyledTripDetails
260
199
  );
261
200
 
@@ -263,11 +202,15 @@ export const BikeTransitBikeItinerary = makeStory({
263
202
  itinerary: bikeTransitBikeItinerary
264
203
  });
265
204
 
266
- export const WalkInterlinedTransitItinerary = makeStory({
267
- defaultFareKey: "electronicRegular",
268
- itinerary: walkInterlinedTransitItinerary,
269
- useCustomFareKeyMap: true
270
- });
205
+ export const WalkInterlinedTransitItinerary = makeStory(
206
+ {
207
+ defaultFareKey: "electronicRegular",
208
+ itinerary: walkInterlinedTransitItinerary
209
+ },
210
+ {
211
+ useCustomFareKeyMap: true
212
+ }
213
+ );
271
214
 
272
215
  export const WalkTransitTransferItinerary = makeStory({
273
216
  itinerary: walkTransitWalkTransitWalkItinerary
@@ -293,18 +236,33 @@ export const EScooterRentalTransitItinerary = makeStory({
293
236
  itinerary: eScooterRentalTransiteScooterRentalItinerary
294
237
  });
295
238
 
296
- export const TncTransitItinerary = makeStory({
297
- itinerary: tncTransitTncItinerary,
298
- useCustomFareKeyMap: true
299
- });
239
+ export const TncTransitItinerary = makeStory(
240
+ {
241
+ itinerary: tncTransitTncItinerary
242
+ },
243
+ {
244
+ useCustomFareKeyMap: true
245
+ }
246
+ );
300
247
 
301
- export const TncTransitItineraryWithCustomDetails = makeStory(
248
+ const flattenedMessages = flatten(customMessages);
249
+ export const TncTransitItineraryWithCustomMessagesAndDetails = makeStory(
302
250
  {
303
251
  CaloriesDetails: CustomCaloriesDetails,
304
252
  defaultFareKey: "electronicRegular",
305
253
  DepartureDetails: CustomDepartureDetails,
306
254
  FareDetails: CustomFareDetails,
307
- itinerary: tncTransitTncItinerary,
255
+ itinerary: tncTransitTncItinerary
256
+ },
257
+ {
258
+ // For illustration purposes,
259
+ // override a subset of localized strings with custom messages.
260
+ reactIntl: {
261
+ messages: {
262
+ "en-US": flattenedMessages,
263
+ fr: flattenedMessages
264
+ }
265
+ },
308
266
  useCustomFareKeyMap: true
309
267
  },
310
268
  StyledTripDetails
package/src/index.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import flatten from "flat";
2
- // @ts-expect-error FIXME: Create TypeScript types for core-utils packages.
2
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
+ // @ts-ignore FIXME: Create TypeScript types for core-utils packages.
3
4
  import coreUtils from "@opentripplanner/core-utils";
4
5
  import { FlexBookingInfo } from "@opentripplanner/types";
5
6
  import React, { ReactElement } from "react";
@@ -131,8 +132,8 @@ const TransitFare = ({
131
132
  name: fareKeyNameMap[fareKey] || fareNameFallback || fareKey,
132
133
  strong: boldText,
133
134
  value: renderFare(
134
- currentFare.currencyCode,
135
- currentFare.transitFare / 100
135
+ currentFare.currency.currencyCode,
136
+ currentFare.cents / 100
136
137
  )
137
138
  }}
138
139
  />
@@ -153,13 +154,9 @@ export function TripDetails({
153
154
  itinerary
154
155
  }: TripDetailsProps): ReactElement {
155
156
  // process the transit fare
156
- const fareResult = coreUtils.itinerary.calculateFares(itinerary, true);
157
- const { maxTNCFare, minTNCFare, tncCurrencyCode, transitFares } = fareResult;
158
-
159
- let defaultFare = defaultFareKey;
160
- if (!transitFares[defaultFareKey]) {
161
- defaultFare = "regular";
162
- }
157
+ const fareResult = coreUtils.itinerary.calculateTncFares(itinerary);
158
+ const { maxTNCFare, minTNCFare, tncCurrencyCode } = fareResult;
159
+ const transitFares = itinerary?.fare?.fare;
163
160
 
164
161
  let companies = "";
165
162
  itinerary.legs.forEach(leg => {
@@ -172,6 +169,11 @@ export function TripDetails({
172
169
  const fareKeys = transitFares && Object.keys(transitFares).sort();
173
170
 
174
171
  if (transitFares && fareKeys.length > 0) {
172
+ let defaultFare = defaultFareKey;
173
+ if (!transitFares[defaultFareKey]) {
174
+ defaultFare = "regular";
175
+ }
176
+
175
177
  // Depending on if there are additional fares to display either render a <span> or a <details>
176
178
  const TransitFareWrapper =
177
179
  transitFares && fareKeys.length > 1 ? S.TransitFare : S.TransitFareSingle;
package/src/types.ts CHANGED
@@ -15,8 +15,13 @@ export interface DepartureDetailsProps {
15
15
 
16
16
  export interface TransitFareData {
17
17
  [key: string]: {
18
- currencyCode: string;
19
- transitFare: number;
18
+ currency: {
19
+ currencyCode: string
20
+ defaultFractionDigits: number
21
+ currency: string
22
+ symbol: string
23
+ };
24
+ cents: number;
20
25
  }
21
26
  }
22
27
 
@@ -187,8 +187,8 @@
187
187
  "affectsGlobalScope": true
188
188
  },
189
189
  "../types/lib/index.d.ts": {
190
- "version": "5e9c49c4c53c0c45da8929a036687a312727692809b47fc06ab9927b174d5a57",
191
- "signature": "5e9c49c4c53c0c45da8929a036687a312727692809b47fc06ab9927b174d5a57",
190
+ "version": "8ca48449e68c83cdea3ef47fae9a693f547b614cdb4acaeed4fa84be29f4bad5",
191
+ "signature": "8ca48449e68c83cdea3ef47fae9a693f547b614cdb4acaeed4fa84be29f4bad5",
192
192
  "affectsGlobalScope": false
193
193
  },
194
194
  "../../node_modules/react-intl/node_modules/@types/react/global.d.ts": {
@@ -197,8 +197,8 @@
197
197
  "affectsGlobalScope": true
198
198
  },
199
199
  "../../node_modules/react-intl/node_modules/@types/react/index.d.ts": {
200
- "version": "c6abad864e3fab7b534a2643ac5e8f5b5dee01aa3e88e141497ccf7f9b181b28",
201
- "signature": "c6abad864e3fab7b534a2643ac5e8f5b5dee01aa3e88e141497ccf7f9b181b28",
200
+ "version": "5a1b30146d105f86b15aaf11ff43af00c29972d18bc3b16c8b8f56aa47801733",
201
+ "signature": "5a1b30146d105f86b15aaf11ff43af00c29972d18bc3b16c8b8f56aa47801733",
202
202
  "affectsGlobalScope": true
203
203
  },
204
204
  "../../node_modules/@formatjs/ecma402-abstract/CanonicalizeLocaleList.d.ts": {
@@ -262,8 +262,8 @@
262
262
  "affectsGlobalScope": false
263
263
  },
264
264
  "../../node_modules/@formatjs/ecma402-abstract/types/number.d.ts": {
265
- "version": "8105c32b75be544cf48eabb59c6db9f869da0607e2206e427fdc4c685979a6a7",
266
- "signature": "8105c32b75be544cf48eabb59c6db9f869da0607e2206e427fdc4c685979a6a7",
265
+ "version": "4c32e274c22c133d96fa3bd1e66af0e213c88d37372598442247e1ea2b3f3616",
266
+ "signature": "4c32e274c22c133d96fa3bd1e66af0e213c88d37372598442247e1ea2b3f3616",
267
267
  "affectsGlobalScope": false
268
268
  },
269
269
  "../../node_modules/@formatjs/ecma402-abstract/NumberFormat/ComputeExponent.d.ts": {
@@ -352,8 +352,8 @@
352
352
  "affectsGlobalScope": false
353
353
  },
354
354
  "../../node_modules/@formatjs/ecma402-abstract/types/date-time.d.ts": {
355
- "version": "da430eb49c948b5e5436a59c791296a6ada26c9f6b7e2fc13e5bbde4228719e8",
356
- "signature": "da430eb49c948b5e5436a59c791296a6ada26c9f6b7e2fc13e5bbde4228719e8",
355
+ "version": "51dc756ec3df8a7599ef0d16268cf7cd429d5d226ceb53cf8f85657a4ade6c29",
356
+ "signature": "51dc756ec3df8a7599ef0d16268cf7cd429d5d226ceb53cf8f85657a4ade6c29",
357
357
  "affectsGlobalScope": false
358
358
  },
359
359
  "../../node_modules/@formatjs/ecma402-abstract/types/list.d.ts": {
@@ -412,8 +412,8 @@
412
412
  "affectsGlobalScope": false
413
413
  },
414
414
  "../../node_modules/intl-messageformat/src/formatters.d.ts": {
415
- "version": "440bce72a5425a259fb1a1b8f680e1b38781be5d64dd3efbcf9fc2cb1120b6a3",
416
- "signature": "440bce72a5425a259fb1a1b8f680e1b38781be5d64dd3efbcf9fc2cb1120b6a3",
415
+ "version": "1135099814b6525159e76fa51f295bf05942f0d9ef84c7030f0a7ad7563531f5",
416
+ "signature": "1135099814b6525159e76fa51f295bf05942f0d9ef84c7030f0a7ad7563531f5",
417
417
  "affectsGlobalScope": false
418
418
  },
419
419
  "../../node_modules/intl-messageformat/src/core.d.ts": {
@@ -442,19 +442,19 @@
442
442
  "affectsGlobalScope": false
443
443
  },
444
444
  "../../node_modules/@formatjs/intl/src/error.d.ts": {
445
- "version": "b31b426b5b87852699da22da5315902404fb985fbf7143e65c010d25a58b2827",
446
- "signature": "b31b426b5b87852699da22da5315902404fb985fbf7143e65c010d25a58b2827",
445
+ "version": "6fd49eaee0916183cccea31985df1f27b81a89eca283e64376c10926436d4fd1",
446
+ "signature": "6fd49eaee0916183cccea31985df1f27b81a89eca283e64376c10926436d4fd1",
447
447
  "affectsGlobalScope": false
448
448
  },
449
449
  "../../node_modules/@formatjs/intl/src/utils.d.ts": {
450
- "version": "60bc916d9674434696b05ba76a48dce0efddb5bb36ef64ee8adba51f92406bbb",
451
- "signature": "60bc916d9674434696b05ba76a48dce0efddb5bb36ef64ee8adba51f92406bbb",
450
+ "version": "248b709d3e86c12a409badb69a4f1ad132438b9189e00096668d097d8082d089",
451
+ "signature": "248b709d3e86c12a409badb69a4f1ad132438b9189e00096668d097d8082d089",
452
452
  "affectsGlobalScope": false
453
453
  },
454
454
  "../../node_modules/@formatjs/intl/src/types.d.ts": {
455
- "version": "73119c8607bdc477e1c00fd8abd205ae7c743594a98d3370e67afb2728847a25",
456
- "signature": "73119c8607bdc477e1c00fd8abd205ae7c743594a98d3370e67afb2728847a25",
457
- "affectsGlobalScope": false
455
+ "version": "7be0ff644833a7105ad4afa61705b1853e4cb6e52d86e449a7d9797f97a57263",
456
+ "signature": "7be0ff644833a7105ad4afa61705b1853e4cb6e52d86e449a7d9797f97a57263",
457
+ "affectsGlobalScope": true
458
458
  },
459
459
  "../../node_modules/@formatjs/intl/src/message.d.ts": {
460
460
  "version": "77cd04a35d49e967b0d566d44452671650a14915b9d7176fa89c5fa87e0e46fd",
@@ -502,8 +502,8 @@
502
502
  "affectsGlobalScope": false
503
503
  },
504
504
  "../../node_modules/react-intl/src/utils.d.ts": {
505
- "version": "771d2bcb81590403114c5c14c8aa6119572050d7fa8b169c6718cd1e5c8cc78b",
506
- "signature": "771d2bcb81590403114c5c14c8aa6119572050d7fa8b169c6718cd1e5c8cc78b",
505
+ "version": "df3a3f23c1125459b7dc5186d2c314d7da4c56cf17c0c637d6f59b06856d7cb2",
506
+ "signature": "df3a3f23c1125459b7dc5186d2c314d7da4c56cf17c0c637d6f59b06856d7cb2",
507
507
  "affectsGlobalScope": false
508
508
  },
509
509
  "../../node_modules/react-intl/src/types.d.ts": {
@@ -522,13 +522,8 @@
522
522
  "affectsGlobalScope": false
523
523
  },
524
524
  "../../node_modules/react-intl/src/components/provider.d.ts": {
525
- "version": "3e5febf5ca9c0380a3b6a155800a13a29887efd9da7e1bcf3a016b628a7ce559",
526
- "signature": "3e5febf5ca9c0380a3b6a155800a13a29887efd9da7e1bcf3a016b628a7ce559",
527
- "affectsGlobalScope": false
528
- },
529
- "../../node_modules/react-intl/src/components/createFormattedComponent.d.ts": {
530
- "version": "9d137a1f88aed0f776de971bc319754673efd28097b31006948d2ed54146db29",
531
- "signature": "9d137a1f88aed0f776de971bc319754673efd28097b31006948d2ed54146db29",
525
+ "version": "01b002cf26575fa47c3a33b200fee5a8300916ad9b94705d3cbc4fdfb0e75a51",
526
+ "signature": "01b002cf26575fa47c3a33b200fee5a8300916ad9b94705d3cbc4fdfb0e75a51",
532
527
  "affectsGlobalScope": false
533
528
  },
534
529
  "../../node_modules/react-intl/src/components/relative.d.ts": {
@@ -542,8 +537,8 @@
542
537
  "affectsGlobalScope": false
543
538
  },
544
539
  "../../node_modules/react-intl/src/components/message.d.ts": {
545
- "version": "dcd09bab5e0e3917472aa6d12709fd824f209340be9a6849d2620fe1662ca7c1",
546
- "signature": "dcd09bab5e0e3917472aa6d12709fd824f209340be9a6849d2620fe1662ca7c1",
540
+ "version": "4fd8fd85ee70843365438aaa5c2faeec87d3f9f186a505b5831f06f0a2c5b237",
541
+ "signature": "4fd8fd85ee70843365438aaa5c2faeec87d3f9f186a505b5831f06f0a2c5b237",
547
542
  "affectsGlobalScope": false
548
543
  },
549
544
  "../../node_modules/react-intl/src/components/dateTimeRange.d.ts": {
@@ -551,9 +546,14 @@
551
546
  "signature": "d4a08b08f4a2ecf0407180e99c8201d724c64ce7ce6137d9ed3b9b6f0f61662e",
552
547
  "affectsGlobalScope": false
553
548
  },
549
+ "../../node_modules/react-intl/src/components/createFormattedComponent.d.ts": {
550
+ "version": "9d137a1f88aed0f776de971bc319754673efd28097b31006948d2ed54146db29",
551
+ "signature": "9d137a1f88aed0f776de971bc319754673efd28097b31006948d2ed54146db29",
552
+ "affectsGlobalScope": false
553
+ },
554
554
  "../../node_modules/react-intl/index.d.ts": {
555
- "version": "665f100adac4de1464e52d92ca9e8a79f85e9f757a3909a6cfd5629bd9d7fe36",
556
- "signature": "665f100adac4de1464e52d92ca9e8a79f85e9f757a3909a6cfd5629bd9d7fe36",
555
+ "version": "516e2ded162ddc84294deb452dda9982b2a938e6df2d7f838ae0fd8b4ed38159",
556
+ "signature": "516e2ded162ddc84294deb452dda9982b2a938e6df2d7f838ae0fd8b4ed38159",
557
557
  "affectsGlobalScope": false
558
558
  },
559
559
  "../../node_modules/@types/hoist-non-react-statics/index.d.ts": {
@@ -622,12 +622,12 @@
622
622
  "affectsGlobalScope": false
623
623
  },
624
624
  "./src/types.ts": {
625
- "version": "6ad0670a4ae39903dc2b79046bb4eb9c68831b5d5f57ebb12ed533406fdf4fdc",
626
- "signature": "ab1e307acd0004ecf08ff282c94eacfa002e5c1eb03027816994b93c69d77ce6",
625
+ "version": "ada7ba841745171d36b98a792d980a98ddbdc78e12c9e71b64d04a193b7101f2",
626
+ "signature": "0137bbd824fc7d71209b0b095d132a6f4e1f536ad1b9e20280ee6979791047c8",
627
627
  "affectsGlobalScope": false
628
628
  },
629
629
  "./src/index.tsx": {
630
- "version": "5e7fdef0f8ac3623d57d5f420d905505b58bf858a725c5424062baad072c0c6d",
630
+ "version": "131af74127dcb03b5f89030b685c4687cded4f935166dc576d1a2a07db0e39e9",
631
631
  "signature": "48768bdf157cc85b94254dd8430e1e3a765de1dfdf2b7605001def58a26daa23",
632
632
  "affectsGlobalScope": false
633
633
  },
@@ -671,11 +671,6 @@
671
671
  "signature": "6f1d39d26959517da3bd105c552eded4c34702705c64d75b03f54d864b6e41c2",
672
672
  "affectsGlobalScope": false
673
673
  },
674
- "../../node_modules/@types/braces/index.d.ts": {
675
- "version": "cfb42d1c8aa66607ef3b1e2cee85d28148358ba62dc5e5146b317dae7bfd9a96",
676
- "signature": "cfb42d1c8aa66607ef3b1e2cee85d28148358ba62dc5e5146b317dae7bfd9a96",
677
- "affectsGlobalScope": false
678
- },
679
674
  "../../node_modules/@types/color-name/index.d.ts": {
680
675
  "version": "f0cb4b3ab88193e3e51e9e2622e4c375955003f1f81239d72c5b7a95415dad3e",
681
676
  "signature": "f0cb4b3ab88193e3e51e9e2622e4c375955003f1f81239d72c5b7a95415dad3e",
@@ -901,21 +896,6 @@
901
896
  "signature": "9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5",
902
897
  "affectsGlobalScope": false
903
898
  },
904
- "../../node_modules/querystring/decode.d.ts": {
905
- "version": "ad7e61eca7f2f8bf47e72695f9f6663b75e41d87ef49abdb17c0cb843862f8aa",
906
- "signature": "ad7e61eca7f2f8bf47e72695f9f6663b75e41d87ef49abdb17c0cb843862f8aa",
907
- "affectsGlobalScope": false
908
- },
909
- "../../node_modules/querystring/encode.d.ts": {
910
- "version": "ecba2e44af95b0599c269a92628cec22e752868bce37396740deb51a5c547a26",
911
- "signature": "ecba2e44af95b0599c269a92628cec22e752868bce37396740deb51a5c547a26",
912
- "affectsGlobalScope": false
913
- },
914
- "../../node_modules/querystring/index.d.ts": {
915
- "version": "46a9fb41a8f3bc7539eeebc15a6e04b9e55d7537a081615ad3614220d34c3e0f",
916
- "signature": "46a9fb41a8f3bc7539eeebc15a6e04b9e55d7537a081615ad3614220d34c3e0f",
917
- "affectsGlobalScope": false
918
- },
919
899
  "../../node_modules/@types/node/url.d.ts": {
920
900
  "version": "dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9",
921
901
  "signature": "dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9",
@@ -991,11 +971,6 @@
991
971
  "signature": "393137c76bd922ba70a2f8bf1ade4f59a16171a02fb25918c168d48875b0cfb0",
992
972
  "affectsGlobalScope": false
993
973
  },
994
- "../../node_modules/@types/glob-base/index.d.ts": {
995
- "version": "d1ae472dde31ac39e68d52e1e21dcccba3989d146b7b8472f03525d0caad1775",
996
- "signature": "d1ae472dde31ac39e68d52e1e21dcccba3989d146b7b8472f03525d0caad1775",
997
- "affectsGlobalScope": false
998
- },
999
974
  "../../node_modules/@types/graceful-fs/index.d.ts": {
1000
975
  "version": "3ebae8c00411116a66fca65b08228ea0cf0b72724701f9b854442100aab55aba",
1001
976
  "signature": "3ebae8c00411116a66fca65b08228ea0cf0b72724701f9b854442100aab55aba",
@@ -1551,21 +1526,11 @@
1551
1526
  "signature": "96d14f21b7652903852eef49379d04dbda28c16ed36468f8c9fa08f7c14c9538",
1552
1527
  "affectsGlobalScope": false
1553
1528
  },
1554
- "../../node_modules/@types/markdown-to-jsx/index.d.ts": {
1555
- "version": "9c138947e4cf970491111d971aa615db8353c7f0efc72bd84d8ad6e4743079c5",
1556
- "signature": "9c138947e4cf970491111d971aa615db8353c7f0efc72bd84d8ad6e4743079c5",
1557
- "affectsGlobalScope": false
1558
- },
1559
1529
  "../../node_modules/@types/mdast/index.d.ts": {
1560
1530
  "version": "9a6d65d77455efaaaeff945bea30c38b8fe0922b807ba45cd23792392f1bfe76",
1561
1531
  "signature": "9a6d65d77455efaaaeff945bea30c38b8fe0922b807ba45cd23792392f1bfe76",
1562
1532
  "affectsGlobalScope": false
1563
1533
  },
1564
- "../../node_modules/@types/micromatch/index.d.ts": {
1565
- "version": "9c36d6df17ca69a65a2a654d9bbd86d74c6d6055e566429cd0a1de82827680eb",
1566
- "signature": "9c36d6df17ca69a65a2a654d9bbd86d74c6d6055e566429cd0a1de82827680eb",
1567
- "affectsGlobalScope": false
1568
- },
1569
1534
  "../../node_modules/@types/minimist/index.d.ts": {
1570
1535
  "version": "e437d83044ba17246a861aa9691aa14223ff4a9d6f338ab1269c41c758586a88",
1571
1536
  "signature": "e437d83044ba17246a861aa9691aa14223ff4a9d6f338ab1269c41c758586a88",
@@ -1626,11 +1591,6 @@
1626
1591
  "signature": "98437d5a640b67c41534f0de2dcb64c75433dcdff54ff8f8432e613663619a2e",
1627
1592
  "affectsGlobalScope": false
1628
1593
  },
1629
- "../../node_modules/@types/reach__router/index.d.ts": {
1630
- "version": "3b280b52be6f8727fbdae05a2ad2c053dac5be97c42a5caa1740e64a2321e935",
1631
- "signature": "3b280b52be6f8727fbdae05a2ad2c053dac5be97c42a5caa1740e64a2321e935",
1632
- "affectsGlobalScope": false
1633
- },
1634
1594
  "../../node_modules/@types/react-syntax-highlighter/index.d.ts": {
1635
1595
  "version": "cffd3848b7af4922d70028c805b7df5e8f0eac4a8d2410b0f55b47ca62c6c3a8",
1636
1596
  "signature": "cffd3848b7af4922d70028c805b7df5e8f0eac4a8d2410b0f55b47ca62c6c3a8",
@@ -1666,6 +1626,11 @@
1666
1626
  "signature": "d558a0fe921ebcc88d3212c2c42108abf9f0d694d67ebdeba37d7728c044f579",
1667
1627
  "affectsGlobalScope": false
1668
1628
  },
1629
+ "../../node_modules/@types/throttle-debounce/index.d.ts": {
1630
+ "version": "4e22b9ea2805fec5f3c120146a690e5604a3117dbdee648c85393f58422eec16",
1631
+ "signature": "4e22b9ea2805fec5f3c120146a690e5604a3117dbdee648c85393f58422eec16",
1632
+ "affectsGlobalScope": false
1633
+ },
1669
1634
  "../../node_modules/source-map/source-map.d.ts": {
1670
1635
  "version": "2887592574fcdfd087647c539dcb0fbe5af2521270dad4a37f9d17c16190d579",
1671
1636
  "signature": "2887592574fcdfd087647c539dcb0fbe5af2521270dad4a37f9d17c16190d579",
@@ -1788,7 +1753,7 @@
1788
1753
  "sourceMap": true,
1789
1754
  "declaration": true,
1790
1755
  "declarationMap": true,
1791
- "noEmitOnError": true,
1756
+ "noEmitOnError": false,
1792
1757
  "skipLibCheck": true,
1793
1758
  "esModuleInterop": true,
1794
1759
  "jsx": 2,
@@ -1972,6 +1937,7 @@
1972
1937
  "../../node_modules/intl-messageformat/index.d.ts"
1973
1938
  ],
1974
1939
  "../../node_modules/@formatjs/intl/src/utils.d.ts": [
1940
+ "../../node_modules/@formatjs/ecma402-abstract/index.d.ts",
1975
1941
  "../../node_modules/@formatjs/intl/src/types.d.ts"
1976
1942
  ],
1977
1943
  "../../node_modules/@styled-icons/fa-solid/CalendarAlt/CalendarAlt.d.ts": [
@@ -2188,15 +2154,9 @@
2188
2154
  "../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts": [
2189
2155
  "../../node_modules/@types/jest/node_modules/pretty-format/build/types.d.ts"
2190
2156
  ],
2191
- "../../node_modules/@types/markdown-to-jsx/index.d.ts": [
2192
- "../../node_modules/@types/react/index.d.ts"
2193
- ],
2194
2157
  "../../node_modules/@types/mdast/index.d.ts": [
2195
2158
  "../../node_modules/@types/unist/index.d.ts"
2196
2159
  ],
2197
- "../../node_modules/@types/micromatch/index.d.ts": [
2198
- "../../node_modules/@types/braces/index.d.ts"
2199
- ],
2200
2160
  "../../node_modules/@types/node-fetch/index.d.ts": [
2201
2161
  "../../node_modules/@types/node-fetch/externals.d.ts",
2202
2162
  "../../node_modules/@types/node-fetch/node_modules/form-data/index.d.ts",
@@ -2409,9 +2369,6 @@
2409
2369
  "../../node_modules/@types/pixelmatch/index.d.ts": [
2410
2370
  "../../node_modules/@types/node/index.d.ts"
2411
2371
  ],
2412
- "../../node_modules/@types/reach__router/index.d.ts": [
2413
- "../../node_modules/@types/react/index.d.ts"
2414
- ],
2415
2372
  "../../node_modules/@types/react-syntax-highlighter/index.d.ts": [
2416
2373
  "../../node_modules/@types/react-syntax-highlighter/index.d.ts",
2417
2374
  "../../node_modules/@types/react/index.d.ts"
@@ -2543,6 +2500,7 @@
2543
2500
  "../../node_modules/intl-messageformat/src/formatters.d.ts"
2544
2501
  ],
2545
2502
  "../../node_modules/intl-messageformat/src/formatters.d.ts": [
2503
+ "../../node_modules/@formatjs/ecma402-abstract/index.d.ts",
2546
2504
  "../../node_modules/@formatjs/icu-messageformat-parser/index.d.ts"
2547
2505
  ],
2548
2506
  "../../node_modules/jest-diff/build/diffLines.d.ts": [
@@ -2559,10 +2517,6 @@
2559
2517
  "../../node_modules/jest-diff/build/cleanupSemantic.d.ts",
2560
2518
  "../../node_modules/jest-diff/build/types.d.ts"
2561
2519
  ],
2562
- "../../node_modules/querystring/index.d.ts": [
2563
- "../../node_modules/querystring/decode.d.ts",
2564
- "../../node_modules/querystring/encode.d.ts"
2565
- ],
2566
2520
  "../../node_modules/react-intl/index.d.ts": [
2567
2521
  "../../node_modules/@formatjs/ecma402-abstract/index.d.ts",
2568
2522
  "../../node_modules/@formatjs/icu-messageformat-parser/index.d.ts",
@@ -3147,6 +3101,7 @@
3147
3101
  "../../node_modules/intl-messageformat/index.d.ts"
3148
3102
  ],
3149
3103
  "../../node_modules/@formatjs/intl/src/utils.d.ts": [
3104
+ "../../node_modules/@formatjs/ecma402-abstract/index.d.ts",
3150
3105
  "../../node_modules/@formatjs/intl/src/types.d.ts"
3151
3106
  ],
3152
3107
  "../../node_modules/@styled-icons/fa-solid/CalendarAlt/CalendarAlt.d.ts": [
@@ -3363,15 +3318,9 @@
3363
3318
  "../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts": [
3364
3319
  "../../node_modules/@types/jest/node_modules/pretty-format/build/types.d.ts"
3365
3320
  ],
3366
- "../../node_modules/@types/markdown-to-jsx/index.d.ts": [
3367
- "../../node_modules/@types/react/index.d.ts"
3368
- ],
3369
3321
  "../../node_modules/@types/mdast/index.d.ts": [
3370
3322
  "../../node_modules/@types/unist/index.d.ts"
3371
3323
  ],
3372
- "../../node_modules/@types/micromatch/index.d.ts": [
3373
- "../../node_modules/@types/braces/index.d.ts"
3374
- ],
3375
3324
  "../../node_modules/@types/node-fetch/index.d.ts": [
3376
3325
  "../../node_modules/@types/node-fetch/externals.d.ts",
3377
3326
  "../../node_modules/@types/node-fetch/node_modules/form-data/index.d.ts",
@@ -3584,9 +3533,6 @@
3584
3533
  "../../node_modules/@types/pixelmatch/index.d.ts": [
3585
3534
  "../../node_modules/@types/node/index.d.ts"
3586
3535
  ],
3587
- "../../node_modules/@types/reach__router/index.d.ts": [
3588
- "../../node_modules/@types/react/index.d.ts"
3589
- ],
3590
3536
  "../../node_modules/@types/react-syntax-highlighter/index.d.ts": [
3591
3537
  "../../node_modules/@types/react-syntax-highlighter/index.d.ts",
3592
3538
  "../../node_modules/@types/react/index.d.ts"
@@ -3718,6 +3664,7 @@
3718
3664
  "../../node_modules/intl-messageformat/src/formatters.d.ts"
3719
3665
  ],
3720
3666
  "../../node_modules/intl-messageformat/src/formatters.d.ts": [
3667
+ "../../node_modules/@formatjs/ecma402-abstract/index.d.ts",
3721
3668
  "../../node_modules/@formatjs/icu-messageformat-parser/index.d.ts"
3722
3669
  ],
3723
3670
  "../../node_modules/jest-diff/build/diffLines.d.ts": [
@@ -3734,10 +3681,6 @@
3734
3681
  "../../node_modules/jest-diff/build/cleanupSemantic.d.ts",
3735
3682
  "../../node_modules/jest-diff/build/types.d.ts"
3736
3683
  ],
3737
- "../../node_modules/querystring/index.d.ts": [
3738
- "../../node_modules/querystring/decode.d.ts",
3739
- "../../node_modules/querystring/encode.d.ts"
3740
- ],
3741
3684
  "../../node_modules/react-intl/index.d.ts": [
3742
3685
  "../../node_modules/@formatjs/ecma402-abstract/index.d.ts",
3743
3686
  "../../node_modules/@formatjs/icu-messageformat-parser/index.d.ts",
@@ -4205,7 +4148,6 @@
4205
4148
  "../../node_modules/@types/babel__generator/index.d.ts",
4206
4149
  "../../node_modules/@types/babel__template/index.d.ts",
4207
4150
  "../../node_modules/@types/babel__traverse/index.d.ts",
4208
- "../../node_modules/@types/braces/index.d.ts",
4209
4151
  "../../node_modules/@types/color-convert/conversions.d.ts",
4210
4152
  "../../node_modules/@types/color-convert/index.d.ts",
4211
4153
  "../../node_modules/@types/color-convert/route.d.ts",
@@ -4213,7 +4155,6 @@
4213
4155
  "../../node_modules/@types/cookie/index.d.ts",
4214
4156
  "../../node_modules/@types/flat/index.d.ts",
4215
4157
  "../../node_modules/@types/geojson/index.d.ts",
4216
- "../../node_modules/@types/glob-base/index.d.ts",
4217
4158
  "../../node_modules/@types/glob/index.d.ts",
4218
4159
  "../../node_modules/@types/graceful-fs/index.d.ts",
4219
4160
  "../../node_modules/@types/hast/index.d.ts",
@@ -4253,9 +4194,7 @@
4253
4194
  "../../node_modules/@types/js-levenshtein/index.d.ts",
4254
4195
  "../../node_modules/@types/json-schema/index.d.ts",
4255
4196
  "../../node_modules/@types/json5/index.d.ts",
4256
- "../../node_modules/@types/markdown-to-jsx/index.d.ts",
4257
4197
  "../../node_modules/@types/mdast/index.d.ts",
4258
- "../../node_modules/@types/micromatch/index.d.ts",
4259
4198
  "../../node_modules/@types/minimatch/index.d.ts",
4260
4199
  "../../node_modules/@types/minimist/index.d.ts",
4261
4200
  "../../node_modules/@types/node-fetch/externals.d.ts",
@@ -4323,7 +4262,6 @@
4323
4262
  "../../node_modules/@types/pretty-hrtime/index.d.ts",
4324
4263
  "../../node_modules/@types/prop-types/index.d.ts",
4325
4264
  "../../node_modules/@types/qs/index.d.ts",
4326
- "../../node_modules/@types/reach__router/index.d.ts",
4327
4265
  "../../node_modules/@types/react-syntax-highlighter/index.d.ts",
4328
4266
  "../../node_modules/@types/react/global.d.ts",
4329
4267
  "../../node_modules/@types/react/index.d.ts",
@@ -4335,6 +4273,7 @@
4335
4273
  "../../node_modules/@types/stack-utils/index.d.ts",
4336
4274
  "../../node_modules/@types/styled-components/index.d.ts",
4337
4275
  "../../node_modules/@types/tapable/index.d.ts",
4276
+ "../../node_modules/@types/throttle-debounce/index.d.ts",
4338
4277
  "../../node_modules/@types/through/index.d.ts",
4339
4278
  "../../node_modules/@types/uglify-js/index.d.ts",
4340
4279
  "../../node_modules/@types/unist/index.d.ts",
@@ -4368,9 +4307,6 @@
4368
4307
  "../../node_modules/jest-diff/build/index.d.ts",
4369
4308
  "../../node_modules/jest-diff/build/printDiffs.d.ts",
4370
4309
  "../../node_modules/jest-diff/build/types.d.ts",
4371
- "../../node_modules/querystring/decode.d.ts",
4372
- "../../node_modules/querystring/encode.d.ts",
4373
- "../../node_modules/querystring/index.d.ts",
4374
4310
  "../../node_modules/react-intl/index.d.ts",
4375
4311
  "../../node_modules/react-intl/node_modules/@types/react/global.d.ts",
4376
4312
  "../../node_modules/react-intl/node_modules/@types/react/index.d.ts",