@opentripplanner/trip-details 5.0.7 → 5.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/fare-table.js +33 -20
- package/esm/fare-table.js.map +1 -1
- package/esm/styled.js +23 -19
- package/esm/styled.js.map +1 -1
- package/i18n/en-US.yml +2 -0
- package/i18n/fr.yml +2 -0
- package/i18n/ko.yml +4 -3
- package/i18n/ru.yml +25 -21
- package/i18n/tl.yml +23 -19
- package/i18n/tr.yml +14 -12
- package/i18n/vi.yml +5 -3
- package/i18n/zh_Hans.yml +4 -3
- package/lib/fare-table.d.ts.map +1 -1
- package/lib/fare-table.js +24 -14
- package/lib/fare-table.js.map +1 -1
- package/lib/styled.d.ts +1 -0
- package/lib/styled.d.ts.map +1 -1
- package/lib/styled.js +27 -20
- package/lib/styled.js.map +1 -1
- package/package.json +3 -3
- package/src/TripDetails.story.tsx +1 -1
- package/src/fare-table.tsx +45 -22
- package/src/styled.ts +9 -0
- package/tsconfig.tsbuildinfo +1 -1
package/lib/fare-table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fare-table.tsx"],"names":["defaultMessages","defaultEnglishMessages","TableHeader","styled","thead","Table","table","TransferIcon","Transfer","useGetHeaderString","headerKey","intl","formatMessage","id","description","defaultMessage","FareTypeTable","cols","legs","colsToRender","map","col","total","mediumId","riderCategoryId","filter","undefined","headerString","filteredLegs","leg","fareProducts","length","fare","columnHeaderKey","currency","code","amount","index","transferAmount","formatNumber","price","currencyDisplay","style","FareLegTable","layout","config"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AAKA;;AADA;AAGA;AACA;AACA;AACA;AACA,MAAMA,eAAuC,GAAG,mBAAQC,aAAR,CAAhD;;AAMA,MAAMC,WAAW,GAAGC,0BAAOC,KAAV;AAAA;AAAA;AAAA,6KAAjB;;AAgBA,MAAMC,KAAK,GAAGF,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import styled from \"styled-components\";\nimport { Transfer } from \"@styled-icons/boxicons-regular/Transfer\";\n\nimport {\n getItineraryCost,\n getLegCost,\n getLegRouteName\n} from \"@opentripplanner/core-utils/lib/itinerary\";\nimport { useIntl } from \"react-intl\";\nimport { flatten } from \"flat\";\nimport { boldText, renderFare } from \"./utils\";\n\nimport { FareLegTableProps, FareTableLayout } 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\ninterface FareTypeTableProps extends FareTableLayout {\n legs: Leg[];\n}\n\nconst TableHeader = styled.thead`\n th {\n font-weight: normal;\n min-width: 5ch;\n padding: 0.75em 1.5em;\n text-align: center;\n }\n th:nth-of-type(2n + 1) {\n background: #cccccc22;\n }\n th.main {\n background: #333333;\n color: #ffffffcc;\n }\n`;\n\nconst Table = styled.table`\n border-collapse: collapse;\n display: block;\n margin-bottom: 16px;\n padding: 0;\n\n td {\n text-align: right;\n }\n td:nth-of-type(2n + 1) {\n background: #cccccc22;\n }\n td.no-zebra {\n background: none;\n }\n th:first-of-type {\n height: 40px;\n }\n`;\n\nconst TransferIcon = styled(Transfer)`\n padding-left: 4px;\n`;\n\nconst useGetHeaderString = (headerKey: string): string => {\n const intl = useIntl();\n return intl.formatMessage({\n id: `otpUi.TripDetails.FareTable.${headerKey}`,\n description: `Fare leg table header for key ${headerKey}`,\n defaultMessage:\n defaultEnglishMessages[`otpUi.TripDetails.FareTable.${headerKey}`]\n });\n};\n\nconst FareTypeTable = ({\n cols,\n headerKey,\n legs\n}: FareTypeTableProps): JSX.Element => {\n const intl = useIntl();\n // FIXME: Is there a nicer way to do this?\n const colsToRender = cols\n .map(col => ({\n ...col,\n total: getItineraryCost(legs, col.mediumId, col.riderCategoryId)\n }))\n .filter(col => col.total !== undefined);\n\n const headerString = useGetHeaderString(headerKey);\n\n const filteredLegs = legs.filter(leg => leg.fareProducts?.length > 0);\n if (colsToRender.length) {\n return (\n <Table>\n <TableHeader>\n <th className=\"main\" scope=\"col\">\n {boldText(headerString)}\n </th>\n {colsToRender.map(col => {\n const fare = col.total;\n return (\n <th\n scope=\"col\"\n key={\n col.columnHeaderKey ||\n `${col.mediumId}-${col.riderCategoryId}`\n }\n >\n {boldText(useGetHeaderString(col.columnHeaderKey))}\n <br />\n {renderFare(fare?.currency?.code, fare?.amount || 0)}\n </th>\n );\n })}\n </TableHeader>\n {filteredLegs.map((leg, index) => (\n <tr key={index}>\n <td className=\"no-zebra\">{getLegRouteName(leg)}</td>\n {colsToRender.map(col => {\n const fare = getLegCost(leg, col.mediumId, col.riderCategoryId);\n return (\n <td\n key={col.columnHeaderKey}\n title={\n \"transferAmount\" in fare &&\n fare?.transferAmount?.amount > 0 &&\n intl.formatMessage(\n {\n defaultMessage:\n defaultMessages[\n \"otpUi.TripDetails.transferDiscountExplanation\"\n ],\n description:\n \"Text explaining the transfer discount applied to this fare.\",\n id: \"otpUi.TripDetails.transferDiscountExplanation\"\n },\n {\n transferAmount: intl.formatNumber(\n fare?.transferAmount?.amount,\n {\n currency: fare?.price?.currency?.code,\n currencyDisplay: \"narrowSymbol\",\n style: \"currency\"\n }\n )\n }\n )\n }\n >\n {\"transferAmount\" in fare &&\n fare?.transferAmount?.amount > 0 && (\n <>\n <TransferIcon size={16} />{\" \"}\n </>\n )}\n {renderFare(\n fare?.price?.currency?.code,\n fare?.price?.amount || 0\n )}\n </td>\n );\n })}\n </tr>\n ))}\n </Table>\n );\n }\n return null;\n};\n\nconst FareLegTable = ({ layout, legs }: FareLegTableProps): JSX.Element => {\n // the layout argument contains an object for every table to be displayed\n return (\n <div>\n {layout.map(config => (\n <FareTypeTable\n cols={config.cols}\n headerKey={config.headerKey}\n key={config.headerKey}\n legs={legs}\n />\n ))}\n </div>\n );\n};\n\nexport default FareLegTable;\n"],"file":"fare-table.js"}
|
|
1
|
+
{"version":3,"sources":["../src/fare-table.tsx"],"names":["defaultMessages","defaultEnglishMessages","TableHeader","styled","thead","Table","table","TransferIcon","Transfer","useGetHeaderString","headerKey","intl","formatMessage","id","description","defaultMessage","hasFareInfo","column","leg","mediumId","riderCategoryId","price","undefined","FareTypeTable","cols","legs","filteredLegs","filter","fareProducts","length","colsToRender","col","some","map","total","every","headerString","fare","columnHeaderKey","amount","currency","code","index","transferAmount","formatNumber","currencyDisplay","style","FareLegTable","layout","config"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AAFA;AAIA;AACA;AACA;AACA;AACA,MAAMA,eAAuC,GAAG,mBAAQC,aAAR,CAAhD;;AAMA,MAAMC,WAAW,GAAGC,0BAAOC,KAAV;AAAA;AAAA;AAAA,6KAAjB;;AAgBA,MAAMC,KAAK,GAAGF,0BAAOG,KAAV;AAAA;AAAA;AAAA,yMAAX;;AAoBA,MAAMC,YAAY,GAAG,+BAAOC,kBAAP,CAAH;AAAA;AAAA;AAAA,yBAAlB;;AAIA,MAAMC,kBAAkB,GAAIC,SAAD,IAA+B;AACxD,QAAMC,IAAI,GAAG,yBAAb;AACA,SAAOA,IAAI,CAACC,aAAL,CAAmB;AACxBC,IAAAA,EAAE,EAAG,+BAA8BH,SAAU,EADrB;AAExBI,IAAAA,WAAW,EAAG,iCAAgCJ,SAAU,EAFhC;AAGxBK,IAAAA,cAAc,EACZd,cAAwB,+BAA8BS,SAAU,EAAhE;AAJsB,GAAnB,CAAP;AAMD,CARD;;AAUA,MAAMM,WAAW,GAAIC,MAAD,IAAkCC,GAAD,IACnD,2BAAWA,GAAX,EAAgBD,MAAM,CAACE,QAAvB,EAAiCF,MAAM,CAACG,eAAxC,EAAyDC,KAAzD,KAAmEC,SADrE;;AAGA,MAAMC,aAAa,GAAG,CAAC;AACrBC,EAAAA,IADqB;AAErBd,EAAAA,SA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,WAFc;AADlB,SAVF;AAJJ,SA2BG,CAAAH,cAAc,SAAd,IAAAA,cAAc,WAAd,YAAAA,cAAc,CAAEJ,MAAhB,IAAyB,CAAzB,iBACC,yEACE,6BAAC,YAAD;AAAc,QAAA,IAAI,EAAE;AAApB,QADF,EAC6B,GAD7B,CA5BJ,EAgCGlB,KAAK,GACJ,uBAAWA,KAAX,aAAWA,KAAX,2CAAWA,KAAK,CAAEmB,QAAlB,qDAAW,iBAAiBC,IAA5B,EAAkCpB,KAAlC,aAAkCA,KAAlC,uBAAkCA,KAAK,CAAEkB,MAAzC,CADI,gBAGJ,8EAEE,6BAAC,0BAAD,qBACE,6BAAC,2BAAD;AAAkB,QAAA,EAAE,EAAC;AAArB,QADF,CAFF,CAnCJ,CADF;AA6CD,KAnDA,CAFH,CADD,CA/BH,CADF;AA2FD;;AACD,SAAO,IAAP;AACD,CAjHD;;AAmHA,MAAMQ,YAAY,GAAG,CAAC;AAAEC,EAAAA,MAAF;AAAUvB,EAAAA;AAAV,CAAD,KAAsD;AACzE;AACA,sBACE,0CACGuB,MAAM,CAACf,GAAP,CAAWgB,MAAM,iBAChB,6BAAC,aAAD;AACE,IAAA,IAAI,EAAEA,MAAM,CAACzB,IADf;AAEE,IAAA,SAAS,EAAEyB,MAAM,CAACvC,SAFpB;AAGE,IAAA,GAAG,EAAEuC,MAAM,CAACvC,SAHd;AAIE,IAAA,IAAI,EAAEe;AAJR,IADD,CADH,CADF;AAYD,CAdD;;eAgBesB,Y","sourcesContent":["import { FareProductSelector, Leg } from \"@opentripplanner/types\";\nimport React from \"react\";\nimport styled from \"styled-components\";\nimport { Transfer } from \"@styled-icons/boxicons-regular/Transfer\";\n\nimport {\n getItineraryCost,\n getLegCost,\n getLegRouteName\n} from \"@opentripplanner/core-utils/lib/itinerary\";\nimport { FormattedMessage, useIntl } from \"react-intl\";\nimport { flatten } from \"flat\";\nimport { boldText, renderFare } from \"./utils\";\n\nimport { FareLegTableProps, FareTableLayout } from \"./types\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\nimport { InvisibleA11yLabel } from \"./styled\";\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\ninterface FareTypeTableProps extends FareTableLayout {\n legs: Leg[];\n}\n\nconst TableHeader = styled.thead`\n th {\n font-weight: normal;\n min-width: 5ch;\n padding: 0.75em 1.5em;\n text-align: center;\n }\n th:nth-of-type(2n + 1) {\n background: #cccccc22;\n }\n th.main {\n background: #333333;\n color: #ffffffcc;\n }\n`;\n\nconst Table = styled.table`\n border-collapse: collapse;\n display: block;\n margin-bottom: 16px;\n padding: 0;\n\n td {\n text-align: right;\n }\n td:nth-of-type(2n + 1) {\n background: #cccccc22;\n }\n td.no-zebra {\n background: none;\n }\n th:first-of-type {\n height: 40px;\n }\n`;\n\nconst TransferIcon = styled(Transfer)`\n padding-left: 4px;\n`;\n\nconst useGetHeaderString = (headerKey: string): string => {\n const intl = useIntl();\n return intl.formatMessage({\n id: `otpUi.TripDetails.FareTable.${headerKey}`,\n description: `Fare leg table header for key ${headerKey}`,\n defaultMessage:\n defaultEnglishMessages[`otpUi.TripDetails.FareTable.${headerKey}`]\n });\n};\n\nconst hasFareInfo = (column: FareProductSelector) => (leg: Leg) =>\n getLegCost(leg, column.mediumId, column.riderCategoryId).price !== undefined;\n\nconst FareTypeTable = ({\n cols,\n headerKey,\n legs\n}: FareTypeTableProps): JSX.Element => {\n const intl = useIntl();\n\n const filteredLegs = legs.filter(leg => leg.fareProducts?.length > 0);\n const colsToRender = cols\n .filter(col => filteredLegs.some(hasFareInfo(col)))\n .map(col => ({\n ...col,\n total: filteredLegs.every(hasFareInfo(col))\n ? getItineraryCost(filteredLegs, col.mediumId, col.riderCategoryId)\n : undefined\n }));\n\n const headerString = useGetHeaderString(headerKey);\n\n if (colsToRender.length) {\n return (\n <Table>\n <TableHeader>\n <th className=\"main\" scope=\"col\">\n {boldText(headerString)}\n </th>\n {colsToRender.map(col => {\n const fare = col.total;\n return (\n <th\n scope=\"col\"\n key={\n col.columnHeaderKey ||\n `${col.mediumId}-${col.riderCategoryId}`\n }\n >\n {boldText(useGetHeaderString(col.columnHeaderKey))}\n <br />\n {fare?.amount !== undefined ? (\n renderFare(fare?.currency?.code, fare?.amount)\n ) : (\n <>\n -\n <InvisibleA11yLabel>\n <FormattedMessage id=\"otpUi.TripDetails.missingFareTotal\" />\n </InvisibleA11yLabel>\n </>\n )}\n </th>\n );\n })}\n </TableHeader>\n {filteredLegs.map((leg, index) => (\n <tr key={index}>\n <td className=\"no-zebra\">{getLegRouteName(leg)}</td>\n {colsToRender.map(col => {\n const { price, transferAmount } = getLegCost(\n leg,\n col.mediumId,\n col.riderCategoryId\n );\n return (\n <td\n key={col.columnHeaderKey}\n title={\n transferAmount?.amount > 0 &&\n intl.formatMessage(\n {\n defaultMessage:\n defaultMessages[\n \"otpUi.TripDetails.transferDiscountExplanation\"\n ],\n description:\n \"Text explaining the transfer discount applied to this fare.\",\n id: \"otpUi.TripDetails.transferDiscountExplanation\"\n },\n {\n transferAmount: intl.formatNumber(\n transferAmount?.amount,\n {\n currency: price?.currency?.code,\n currencyDisplay: \"narrowSymbol\",\n style: \"currency\"\n }\n )\n }\n )\n }\n >\n {transferAmount?.amount > 0 && (\n <>\n <TransferIcon size={16} />{\" \"}\n </>\n )}\n {price ? (\n renderFare(price?.currency?.code, price?.amount)\n ) : (\n <>\n -\n <InvisibleA11yLabel>\n <FormattedMessage id=\"otpUi.TripDetails.legMissingFareInfo\" />\n </InvisibleA11yLabel>\n </>\n )}\n </td>\n );\n })}\n </tr>\n ))}\n </Table>\n );\n }\n return null;\n};\n\nconst FareLegTable = ({ layout, legs }: FareLegTableProps): JSX.Element => {\n // the layout argument contains an object for every table to be displayed\n return (\n <div>\n {layout.map(config => (\n <FareTypeTable\n cols={config.cols}\n headerKey={config.headerKey}\n key={config.headerKey}\n legs={legs}\n />\n ))}\n </div>\n );\n};\n\nexport default FareLegTable;\n"],"file":"fare-table.js"}
|
package/lib/styled.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const InvisibleA11yLabel: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
1
2
|
export declare const CO2Description: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
2
3
|
export declare const CO2Summary: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
3
4
|
export declare const ExpandButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
package/lib/styled.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,qEAO9B,CAAC;AAmBF,eAAO,MAAM,cAAc,qEAAgB,CAAC;AAE5C,eAAO,MAAM,UAAU,qEAAgB,CAAC;AAExC,eAAO,MAAM,YAAY,uEAKxB,CAAC;AAEF,eAAO,MAAM,IAAI,qEAAgB,CAAC;AAElC,eAAO,MAAM,UAAU,uEAEtB,CAAC;AAEF,eAAO,MAAM,OAAO,qEAAgB,CAAC;AAErC,eAAO,MAAM,gBAAgB,qEAE5B,CAAC;AAEF,eAAO,MAAM,MAAM,qEAAgB,CAAC;AAEpC,eAAO,MAAM,WAAW,wEASvB,CAAC;AACF,eAAO,MAAM,iBAAiB,qEAAgB,CAAC;AAE/C,eAAO,MAAM,WAAW,qEAAgB,CAAC;AAEzC,eAAO,MAAM,UAAU,oEAEtB,CAAC;AAEF,eAAO,MAAM,qBAAqB,oEAMjC,CAAC;AAEF,eAAO,MAAM,cAAc,oEAG1B,CAAC;AAEF,eAAO,MAAM,WAAW,oEAMvB,CAAC;AAEF,eAAO,MAAM,eAAe,oEAAe,CAAC;AAE5C,eAAO,MAAM,iBAAiB,mEAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,oEAM7B,CAAC"}
|
package/lib/styled.js
CHANGED
|
@@ -5,133 +5,140 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.TripDetailSummary = exports.TripDetailsHeader = exports.TripDetailsBody = exports.TripDetails = exports.TripDetailIcon = exports.TripDetailDescription = exports.TripDetail = exports.FlexSummary = exports.TransitFareSingle = exports.TransitFare = exports.Timing = exports.TNCFareCompanies = exports.TNCFare = exports.HideButton = exports.Fare = exports.ExpandButton = exports.CO2Summary = exports.CO2Description = void 0;
|
|
8
|
+
exports.TripDetailSummary = exports.TripDetailsHeader = exports.TripDetailsBody = exports.TripDetails = exports.TripDetailIcon = exports.TripDetailDescription = exports.TripDetail = exports.FlexSummary = exports.TransitFareSingle = exports.TransitFare = exports.Timing = exports.TNCFareCompanies = exports.TNCFare = exports.HideButton = exports.Fare = exports.ExpandButton = exports.CO2Summary = exports.CO2Description = exports.InvisibleA11yLabel = void 0;
|
|
9
9
|
|
|
10
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
11
|
|
|
12
|
+
const InvisibleA11yLabel = _styledComponents.default.span.withConfig({
|
|
13
|
+
displayName: "styled__InvisibleA11yLabel",
|
|
14
|
+
componentId: "sc-6q2ok2-0"
|
|
15
|
+
})(["display:inline-block;clip:rect(0,0,0,0);height:0;overflow:hidden;position:absolute;width:0;"]);
|
|
16
|
+
|
|
17
|
+
exports.InvisibleA11yLabel = InvisibleA11yLabel;
|
|
18
|
+
|
|
12
19
|
const BaseButton = _styledComponents.default.button.withConfig({
|
|
13
20
|
displayName: "styled__BaseButton",
|
|
14
|
-
componentId: "sc-6q2ok2-
|
|
21
|
+
componentId: "sc-6q2ok2-1"
|
|
15
22
|
})(["background:transparent;border:0;cursor:pointer;display:inline-block;font-size:14px;font-weight:400;line-height:1.42857143;margin:0;padding:0;text-decoration:none;touch-action:manipulation;user-select:none;vertical-align:middle;white-space:nowrap;"]);
|
|
16
23
|
|
|
17
24
|
const CO2Description = _styledComponents.default.span.withConfig({
|
|
18
25
|
displayName: "styled__CO2Description",
|
|
19
|
-
componentId: "sc-6q2ok2-
|
|
26
|
+
componentId: "sc-6q2ok2-2"
|
|
20
27
|
})([""]);
|
|
21
28
|
|
|
22
29
|
exports.CO2Description = CO2Description;
|
|
23
30
|
|
|
24
31
|
const CO2Summary = _styledComponents.default.span.withConfig({
|
|
25
32
|
displayName: "styled__CO2Summary",
|
|
26
|
-
componentId: "sc-6q2ok2-
|
|
33
|
+
componentId: "sc-6q2ok2-3"
|
|
27
34
|
})([""]);
|
|
28
35
|
|
|
29
36
|
exports.CO2Summary = CO2Summary;
|
|
30
37
|
const ExpandButton = (0, _styledComponents.default)(BaseButton).withConfig({
|
|
31
38
|
displayName: "styled__ExpandButton",
|
|
32
|
-
componentId: "sc-6q2ok2-
|
|
39
|
+
componentId: "sc-6q2ok2-4"
|
|
33
40
|
})(["color:#00f;font-size:16px;margin-left:6px;margin-top:-2px;"]);
|
|
34
41
|
exports.ExpandButton = ExpandButton;
|
|
35
42
|
|
|
36
43
|
const Fare = _styledComponents.default.span.withConfig({
|
|
37
44
|
displayName: "styled__Fare",
|
|
38
|
-
componentId: "sc-6q2ok2-
|
|
45
|
+
componentId: "sc-6q2ok2-5"
|
|
39
46
|
})([""]);
|
|
40
47
|
|
|
41
48
|
exports.Fare = Fare;
|
|
42
49
|
const HideButton = (0, _styledComponents.default)(BaseButton).withConfig({
|
|
43
50
|
displayName: "styled__HideButton",
|
|
44
|
-
componentId: "sc-6q2ok2-
|
|
51
|
+
componentId: "sc-6q2ok2-6"
|
|
45
52
|
})(["float:right;"]);
|
|
46
53
|
exports.HideButton = HideButton;
|
|
47
54
|
|
|
48
55
|
const TNCFare = _styledComponents.default.span.withConfig({
|
|
49
56
|
displayName: "styled__TNCFare",
|
|
50
|
-
componentId: "sc-6q2ok2-
|
|
57
|
+
componentId: "sc-6q2ok2-7"
|
|
51
58
|
})([""]);
|
|
52
59
|
|
|
53
60
|
exports.TNCFare = TNCFare;
|
|
54
61
|
|
|
55
62
|
const TNCFareCompanies = _styledComponents.default.span.withConfig({
|
|
56
63
|
displayName: "styled__TNCFareCompanies",
|
|
57
|
-
componentId: "sc-6q2ok2-
|
|
64
|
+
componentId: "sc-6q2ok2-8"
|
|
58
65
|
})(["text-transform:capitalize;"]);
|
|
59
66
|
|
|
60
67
|
exports.TNCFareCompanies = TNCFareCompanies;
|
|
61
68
|
|
|
62
69
|
const Timing = _styledComponents.default.span.withConfig({
|
|
63
70
|
displayName: "styled__Timing",
|
|
64
|
-
componentId: "sc-6q2ok2-
|
|
71
|
+
componentId: "sc-6q2ok2-9"
|
|
65
72
|
})([""]);
|
|
66
73
|
|
|
67
74
|
exports.Timing = Timing;
|
|
68
75
|
|
|
69
76
|
const TransitFare = _styledComponents.default.details.withConfig({
|
|
70
77
|
displayName: "styled__TransitFare",
|
|
71
|
-
componentId: "sc-6q2ok2-
|
|
78
|
+
componentId: "sc-6q2ok2-10"
|
|
72
79
|
})(["display:inline-block;> span{display:block;padding-left:1.75ch;}"]);
|
|
73
80
|
|
|
74
81
|
exports.TransitFare = TransitFare;
|
|
75
82
|
|
|
76
83
|
const TransitFareSingle = _styledComponents.default.span.withConfig({
|
|
77
84
|
displayName: "styled__TransitFareSingle",
|
|
78
|
-
componentId: "sc-6q2ok2-
|
|
85
|
+
componentId: "sc-6q2ok2-11"
|
|
79
86
|
})([""]);
|
|
80
87
|
|
|
81
88
|
exports.TransitFareSingle = TransitFareSingle;
|
|
82
89
|
|
|
83
90
|
const FlexSummary = _styledComponents.default.span.withConfig({
|
|
84
91
|
displayName: "styled__FlexSummary",
|
|
85
|
-
componentId: "sc-6q2ok2-
|
|
92
|
+
componentId: "sc-6q2ok2-12"
|
|
86
93
|
})([""]);
|
|
87
94
|
|
|
88
95
|
exports.FlexSummary = FlexSummary;
|
|
89
96
|
|
|
90
97
|
const TripDetail = _styledComponents.default.div.withConfig({
|
|
91
98
|
displayName: "styled__TripDetail",
|
|
92
|
-
componentId: "sc-6q2ok2-
|
|
99
|
+
componentId: "sc-6q2ok2-13"
|
|
93
100
|
})(["margin-top:6px;"]);
|
|
94
101
|
|
|
95
102
|
exports.TripDetail = TripDetail;
|
|
96
103
|
|
|
97
104
|
const TripDetailDescription = _styledComponents.default.div.withConfig({
|
|
98
105
|
displayName: "styled__TripDetailDescription",
|
|
99
|
-
componentId: "sc-6q2ok2-
|
|
106
|
+
componentId: "sc-6q2ok2-14"
|
|
100
107
|
})(["background-color:#fff;border:1px solid #888;font-size:12px;margin-top:2px;padding:8px;"]);
|
|
101
108
|
|
|
102
109
|
exports.TripDetailDescription = TripDetailDescription;
|
|
103
110
|
|
|
104
111
|
const TripDetailIcon = _styledComponents.default.div.withConfig({
|
|
105
112
|
displayName: "styled__TripDetailIcon",
|
|
106
|
-
componentId: "sc-6q2ok2-
|
|
113
|
+
componentId: "sc-6q2ok2-15"
|
|
107
114
|
})(["float:left;font-size:17px;"]);
|
|
108
115
|
|
|
109
116
|
exports.TripDetailIcon = TripDetailIcon;
|
|
110
117
|
|
|
111
118
|
const TripDetails = _styledComponents.default.div.withConfig({
|
|
112
119
|
displayName: "styled__TripDetails",
|
|
113
|
-
componentId: "sc-6q2ok2-
|
|
120
|
+
componentId: "sc-6q2ok2-16"
|
|
114
121
|
})(["background-color:#eee;border-radius:6px;margin-bottom:15px;margin-top:16px;padding:10px 16px;"]);
|
|
115
122
|
|
|
116
123
|
exports.TripDetails = TripDetails;
|
|
117
124
|
|
|
118
125
|
const TripDetailsBody = _styledComponents.default.div.withConfig({
|
|
119
126
|
displayName: "styled__TripDetailsBody",
|
|
120
|
-
componentId: "sc-6q2ok2-
|
|
127
|
+
componentId: "sc-6q2ok2-17"
|
|
121
128
|
})([""]);
|
|
122
129
|
|
|
123
130
|
exports.TripDetailsBody = TripDetailsBody;
|
|
124
131
|
|
|
125
132
|
const TripDetailsHeader = _styledComponents.default.h2.withConfig({
|
|
126
133
|
displayName: "styled__TripDetailsHeader",
|
|
127
|
-
componentId: "sc-6q2ok2-
|
|
134
|
+
componentId: "sc-6q2ok2-18"
|
|
128
135
|
})(["font-size:18px;font-weight:600;margin:0;"]);
|
|
129
136
|
|
|
130
137
|
exports.TripDetailsHeader = TripDetailsHeader;
|
|
131
138
|
|
|
132
139
|
const TripDetailSummary = _styledComponents.default.div.withConfig({
|
|
133
140
|
displayName: "styled__TripDetailSummary",
|
|
134
|
-
componentId: "sc-6q2ok2-
|
|
141
|
+
componentId: "sc-6q2ok2-19"
|
|
135
142
|
})(["margin-left:28px;padding-top:2px;display:flex;align-items:baseline;white-space:pre;"]);
|
|
136
143
|
|
|
137
144
|
exports.TripDetailSummary = TripDetailSummary;
|
package/lib/styled.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/styled.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/styled.ts"],"names":["InvisibleA11yLabel","styled","span","BaseButton","button","CO2Description","CO2Summary","ExpandButton","Fare","HideButton","TNCFare","TNCFareCompanies","Timing","TransitFare","details","TransitFareSingle","FlexSummary","TripDetail","div","TripDetailDescription","TripDetailIcon","TripDetails","TripDetailsBody","TripDetailsHeader","h2","TripDetailSummary"],"mappings":";;;;;;;;;AAAA;;AAEO,MAAMA,kBAAkB,GAAGC,0BAAOC,IAAV;AAAA;AAAA;AAAA,mGAAxB;;;;AASP,MAAMC,UAAU,GAAGF,0BAAOG,MAAV;AAAA;AAAA;AAAA,8PAAhB;;AAiBO,MAAMC,cAAc,GAAGJ,0BAAOC,IAAV;AAAA;AAAA;AAAA,QAApB;;;;AAEA,MAAMI,UAAU,GAAGL,0BAAOC,IAAV;AAAA;AAAA;AAAA,QAAhB;;;AAEA,MAAMK,YAAY,G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overflow: hidden;\n position: absolute;\n width: 0;\n`;\n\nconst BaseButton = styled.button`\n background: transparent;\n border: 0;\n cursor: pointer;\n display: inline-block;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n margin: 0;\n padding: 0;\n text-decoration: none;\n touch-action: manipulation;\n user-select: none;\n vertical-align: middle;\n white-space: nowrap;\n`;\n\nexport const CO2Description = styled.span``;\n\nexport const CO2Summary = styled.span``;\n\nexport const ExpandButton = styled(BaseButton)`\n color: #00f;\n font-size: 16px;\n margin-left: 6px;\n margin-top: -2px;\n`;\n\nexport const Fare = styled.span``;\n\nexport const HideButton = styled(BaseButton)`\n float: right;\n`;\n\nexport const TNCFare = styled.span``;\n\nexport const TNCFareCompanies = styled.span`\n text-transform: capitalize;\n`;\n\nexport const Timing = styled.span``;\n\nexport const TransitFare = styled.details`\n display: inline-block;\n\n > span {\n display: block;\n /* This may seem wrong, but this value gives the most aligned results */\n /* see: https://github.com/opentripplanner/otp-ui/pull/294#discussion_r742045851 */\n padding-left: 1.75ch;\n }\n`;\nexport const TransitFareSingle = styled.span``;\n\nexport const FlexSummary = styled.span``;\n\nexport const TripDetail = styled.div`\n margin-top: 6px;\n`;\n\nexport const TripDetailDescription = styled.div`\n background-color: #fff;\n border: 1px solid #888;\n font-size: 12px;\n margin-top: 2px;\n padding: 8px;\n`;\n\nexport const TripDetailIcon = styled.div`\n float: left;\n font-size: 17px;\n`;\n\nexport const TripDetails = styled.div`\n background-color: #eee;\n border-radius: 6px;\n margin-bottom: 15px;\n margin-top: 16px;\n padding: 10px 16px;\n`;\n\nexport const TripDetailsBody = styled.div``;\n\nexport const TripDetailsHeader = styled.h2`\n font-size: 18px;\n font-weight: 600;\n margin: 0;\n`;\n\nexport const TripDetailSummary = styled.div`\n margin-left: 28px;\n padding-top: 2px;\n display: flex;\n align-items: baseline;\n white-space: pre;\n`;\n"],"file":"styled.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentripplanner/trip-details",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.8",
|
|
4
4
|
"description": "A component for displaying details about a trip planning itinerary",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"private": false,
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@opentripplanner/core-utils": "^11.
|
|
14
|
+
"@opentripplanner/core-utils": "^11.1.3",
|
|
15
15
|
"@styled-icons/fa-solid": "^10.34.0",
|
|
16
16
|
"flat": "^5.0.2",
|
|
17
17
|
"react-animate-height": "^3.0.4"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@opentripplanner/types": "^6.
|
|
20
|
+
"@opentripplanner/types": "^6.2.1",
|
|
21
21
|
"@types/flat": "^5.0.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
StoryContext
|
|
9
9
|
} from "@storybook/react";
|
|
10
10
|
import styled from "styled-components";
|
|
11
|
-
// The below eslint-disable is due to https://github.com/storybookjs/storybook/issues/13408
|
|
12
11
|
import { convertGraphQLResponseToLegacy } from "@opentripplanner/core-utils/lib/itinerary";
|
|
12
|
+
// The below eslint-disable is due to https://github.com/storybookjs/storybook/issues/13408
|
|
13
13
|
// eslint-disable-next-line import/no-named-as-default
|
|
14
14
|
import TripDetails, { FareLegTable } from ".";
|
|
15
15
|
import * as TripDetailsClasses from "./styled";
|
package/src/fare-table.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Leg } from "@opentripplanner/types";
|
|
1
|
+
import { FareProductSelector, Leg } from "@opentripplanner/types";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import styled from "styled-components";
|
|
4
4
|
import { Transfer } from "@styled-icons/boxicons-regular/Transfer";
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
getLegCost,
|
|
9
9
|
getLegRouteName
|
|
10
10
|
} from "@opentripplanner/core-utils/lib/itinerary";
|
|
11
|
-
import { useIntl } from "react-intl";
|
|
11
|
+
import { FormattedMessage, useIntl } from "react-intl";
|
|
12
12
|
import { flatten } from "flat";
|
|
13
13
|
import { boldText, renderFare } from "./utils";
|
|
14
14
|
|
|
@@ -16,6 +16,7 @@ import { FareLegTableProps, FareTableLayout } from "./types";
|
|
|
16
16
|
|
|
17
17
|
// Load the default messages.
|
|
18
18
|
import defaultEnglishMessages from "../i18n/en-US.yml";
|
|
19
|
+
import { InvisibleA11yLabel } from "./styled";
|
|
19
20
|
|
|
20
21
|
// HACK: We should flatten the messages loaded above because
|
|
21
22
|
// the YAML loaders behave differently between webpack and our version of jest:
|
|
@@ -77,23 +78,28 @@ const useGetHeaderString = (headerKey: string): string => {
|
|
|
77
78
|
});
|
|
78
79
|
};
|
|
79
80
|
|
|
81
|
+
const hasFareInfo = (column: FareProductSelector) => (leg: Leg) =>
|
|
82
|
+
getLegCost(leg, column.mediumId, column.riderCategoryId).price !== undefined;
|
|
83
|
+
|
|
80
84
|
const FareTypeTable = ({
|
|
81
85
|
cols,
|
|
82
86
|
headerKey,
|
|
83
87
|
legs
|
|
84
88
|
}: FareTypeTableProps): JSX.Element => {
|
|
85
89
|
const intl = useIntl();
|
|
86
|
-
|
|
90
|
+
|
|
91
|
+
const filteredLegs = legs.filter(leg => leg.fareProducts?.length > 0);
|
|
87
92
|
const colsToRender = cols
|
|
93
|
+
.filter(col => filteredLegs.some(hasFareInfo(col)))
|
|
88
94
|
.map(col => ({
|
|
89
95
|
...col,
|
|
90
|
-
total:
|
|
91
|
-
|
|
92
|
-
|
|
96
|
+
total: filteredLegs.every(hasFareInfo(col))
|
|
97
|
+
? getItineraryCost(filteredLegs, col.mediumId, col.riderCategoryId)
|
|
98
|
+
: undefined
|
|
99
|
+
}));
|
|
93
100
|
|
|
94
101
|
const headerString = useGetHeaderString(headerKey);
|
|
95
102
|
|
|
96
|
-
const filteredLegs = legs.filter(leg => leg.fareProducts?.length > 0);
|
|
97
103
|
if (colsToRender.length) {
|
|
98
104
|
return (
|
|
99
105
|
<Table>
|
|
@@ -113,7 +119,16 @@ const FareTypeTable = ({
|
|
|
113
119
|
>
|
|
114
120
|
{boldText(useGetHeaderString(col.columnHeaderKey))}
|
|
115
121
|
<br />
|
|
116
|
-
{
|
|
122
|
+
{fare?.amount !== undefined ? (
|
|
123
|
+
renderFare(fare?.currency?.code, fare?.amount)
|
|
124
|
+
) : (
|
|
125
|
+
<>
|
|
126
|
+
-
|
|
127
|
+
<InvisibleA11yLabel>
|
|
128
|
+
<FormattedMessage id="otpUi.TripDetails.missingFareTotal" />
|
|
129
|
+
</InvisibleA11yLabel>
|
|
130
|
+
</>
|
|
131
|
+
)}
|
|
117
132
|
</th>
|
|
118
133
|
);
|
|
119
134
|
})}
|
|
@@ -122,13 +137,16 @@ const FareTypeTable = ({
|
|
|
122
137
|
<tr key={index}>
|
|
123
138
|
<td className="no-zebra">{getLegRouteName(leg)}</td>
|
|
124
139
|
{colsToRender.map(col => {
|
|
125
|
-
const
|
|
140
|
+
const { price, transferAmount } = getLegCost(
|
|
141
|
+
leg,
|
|
142
|
+
col.mediumId,
|
|
143
|
+
col.riderCategoryId
|
|
144
|
+
);
|
|
126
145
|
return (
|
|
127
146
|
<td
|
|
128
147
|
key={col.columnHeaderKey}
|
|
129
148
|
title={
|
|
130
|
-
|
|
131
|
-
fare?.transferAmount?.amount > 0 &&
|
|
149
|
+
transferAmount?.amount > 0 &&
|
|
132
150
|
intl.formatMessage(
|
|
133
151
|
{
|
|
134
152
|
defaultMessage:
|
|
@@ -141,9 +159,9 @@ const FareTypeTable = ({
|
|
|
141
159
|
},
|
|
142
160
|
{
|
|
143
161
|
transferAmount: intl.formatNumber(
|
|
144
|
-
|
|
162
|
+
transferAmount?.amount,
|
|
145
163
|
{
|
|
146
|
-
currency:
|
|
164
|
+
currency: price?.currency?.code,
|
|
147
165
|
currencyDisplay: "narrowSymbol",
|
|
148
166
|
style: "currency"
|
|
149
167
|
}
|
|
@@ -152,15 +170,20 @@ const FareTypeTable = ({
|
|
|
152
170
|
)
|
|
153
171
|
}
|
|
154
172
|
>
|
|
155
|
-
{
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
173
|
+
{transferAmount?.amount > 0 && (
|
|
174
|
+
<>
|
|
175
|
+
<TransferIcon size={16} />{" "}
|
|
176
|
+
</>
|
|
177
|
+
)}
|
|
178
|
+
{price ? (
|
|
179
|
+
renderFare(price?.currency?.code, price?.amount)
|
|
180
|
+
) : (
|
|
181
|
+
<>
|
|
182
|
+
-
|
|
183
|
+
<InvisibleA11yLabel>
|
|
184
|
+
<FormattedMessage id="otpUi.TripDetails.legMissingFareInfo" />
|
|
185
|
+
</InvisibleA11yLabel>
|
|
186
|
+
</>
|
|
164
187
|
)}
|
|
165
188
|
</td>
|
|
166
189
|
);
|
package/src/styled.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
|
|
3
|
+
export const InvisibleA11yLabel = styled.span`
|
|
4
|
+
display: inline-block;
|
|
5
|
+
clip: rect(0, 0, 0, 0);
|
|
6
|
+
height: 0;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
position: absolute;
|
|
9
|
+
width: 0;
|
|
10
|
+
`;
|
|
11
|
+
|
|
3
12
|
const BaseButton = styled.button`
|
|
4
13
|
background: transparent;
|
|
5
14
|
border: 0;
|