@opentripplanner/trip-details 2.1.0-alpha.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/utils.tsx ADDED
@@ -0,0 +1,30 @@
1
+ import React, { ReactElement } from "react";
2
+ import { FormattedNumber } from "react-intl";
3
+
4
+ /**
5
+ * Format text bold (used with FormattedMessage).
6
+ */
7
+ export function boldText(contents: ReactElement): ReactElement {
8
+ return <strong>{contents}</strong>;
9
+ }
10
+
11
+ /**
12
+ * Render formatted fare.
13
+ * @param currencyCode The ISO currency code to use (USD, GBP, EUR).
14
+ * @param fare The fare value, in currency units, to be shown.
15
+ * @returns The formatted fare value according to the selected locale.
16
+ */
17
+ export function renderFare(currencyCode: string, fare: number): ReactElement {
18
+ return (
19
+ <FormattedNumber
20
+ currency={currencyCode}
21
+ // For dollars in locales such as 'fr',
22
+ // this will limit the display to just the dollar sign
23
+ // (otherwise it will render e.g. '2,50 $US' instead of '2,50 $').
24
+ currencyDisplay="narrowSymbol"
25
+ value={fare}
26
+ // eslint-disable-next-line react/style-prop-object
27
+ style="currency"
28
+ />
29
+ );
30
+ }
@@ -182,8 +182,13 @@
182
182
  "affectsGlobalScope": true
183
183
  },
184
184
  "../types/lib/index.d.ts": {
185
- "version": "0fa8e07eac37ef7aa4b3736dd0a99c57e534d552a6ea6a287a4194f8147ff6d1",
186
- "signature": "0fa8e07eac37ef7aa4b3736dd0a99c57e534d552a6ea6a287a4194f8147ff6d1",
185
+ "version": "329a87eef5d7da893a8b9ac9a3debac348ebd3c034c64393483e85c31e3edea2",
186
+ "signature": "329a87eef5d7da893a8b9ac9a3debac348ebd3c034c64393483e85c31e3edea2",
187
+ "affectsGlobalScope": false
188
+ },
189
+ "../../node_modules/@types/flat/index.d.ts": {
190
+ "version": "d9890ea8f1da57be3c2e2d3627b787cd4b4a463fd1747c823a0de24b240c8fe5",
191
+ "signature": "d9890ea8f1da57be3c2e2d3627b787cd4b4a463fd1747c823a0de24b240c8fe5",
187
192
  "affectsGlobalScope": false
188
193
  },
189
194
  "../../node_modules/@types/hoist-non-react-statics/index.d.ts": {
@@ -561,19 +566,29 @@
561
566
  "signature": "516e2ded162ddc84294deb452dda9982b2a938e6df2d7f838ae0fd8b4ed38159",
562
567
  "affectsGlobalScope": false
563
568
  },
564
- "./src/types.ts": {
565
- "version": "0075a86cc3a30ce76e89a5639fd11942854a6cdf339d1dcd5b122ba86af317f2",
566
- "signature": "22b8c720a2a78a9bb5f979333573442382cb4ec6ad43f0080b3e0d7961e36e16",
569
+ "../../node_modules/@styled-icons/styled-icon/index.d.ts": {
570
+ "version": "a4ce8cb63b46ff55db10c4bdd3007240a42ba71c03f159ea7e6517aef9a8013c",
571
+ "signature": "a4ce8cb63b46ff55db10c4bdd3007240a42ba71c03f159ea7e6517aef9a8013c",
567
572
  "affectsGlobalScope": false
568
573
  },
569
- "./src/fare-detail.tsx": {
570
- "version": "c2345b34cbf8fb8c7b27f160639430b98062e19b4ec58a25b5c9d218b751eba7",
571
- "signature": "e70353df638fac658f3989e9855f94522e9e1c4bf7541734a9742abe69666aa0",
574
+ "../../node_modules/@styled-icons/boxicons-regular/Transfer/Transfer.d.ts": {
575
+ "version": "8a237d3bc8b7d9d4aa2f03d3ada1c230493177df302d91f9da46d69b730f0d9c",
576
+ "signature": "8a237d3bc8b7d9d4aa2f03d3ada1c230493177df302d91f9da46d69b730f0d9c",
572
577
  "affectsGlobalScope": false
573
578
  },
574
- "../../node_modules/@types/flat/index.d.ts": {
575
- "version": "d9890ea8f1da57be3c2e2d3627b787cd4b4a463fd1747c823a0de24b240c8fe5",
576
- "signature": "d9890ea8f1da57be3c2e2d3627b787cd4b4a463fd1747c823a0de24b240c8fe5",
579
+ "./src/utils.tsx": {
580
+ "version": "f05b036e2c3a090da6dd6852320669d527389a929553de8d5fb067c9c7bfd38f",
581
+ "signature": "624668423c973a8a094b3584213fab36eff916bbae1e0d8d7274fb965d5573e4",
582
+ "affectsGlobalScope": false
583
+ },
584
+ "./src/types.ts": {
585
+ "version": "fc9506a4a6146bb9856a0e34b5cee3279faea61eac4524715bc34dc03a4426bc",
586
+ "signature": "553ab0db0248d31cd01a74e330b2bf5cd81455a93c5ce3756dbc77c2958deb06",
587
+ "affectsGlobalScope": false
588
+ },
589
+ "./src/fare-table.tsx": {
590
+ "version": "89df602ed8bf89c43d62c52fb8a9e9929febfd2b2d23aa37a52f72f5c6c0a5c5",
591
+ "signature": "1b9c102a52d0490c6167c6454a0ef848fbe240bd49c98064f02481056947cea9",
577
592
  "affectsGlobalScope": false
578
593
  },
579
594
  "./node_modules/@opentripplanner/core-utils/lib/itinerary.d.ts": {
@@ -616,11 +631,6 @@
616
631
  "signature": "1d70ffdcee3aaa052be9562efd39d3b97c5ece8cc3ebb190eed4205c2201674a",
617
632
  "affectsGlobalScope": false
618
633
  },
619
- "../../node_modules/@styled-icons/styled-icon/index.d.ts": {
620
- "version": "a4ce8cb63b46ff55db10c4bdd3007240a42ba71c03f159ea7e6517aef9a8013c",
621
- "signature": "a4ce8cb63b46ff55db10c4bdd3007240a42ba71c03f159ea7e6517aef9a8013c",
622
- "affectsGlobalScope": false
623
- },
624
634
  "../../node_modules/@styled-icons/fa-solid/CalendarAlt/CalendarAlt.d.ts": {
625
635
  "version": "0f45bc35aa17950b1198b3db89c3103736a925f3977086cfce73eca8cb725563",
626
636
  "signature": "0f45bc35aa17950b1198b3db89c3103736a925f3977086cfce73eca8cb725563",
@@ -672,8 +682,8 @@
672
682
  "affectsGlobalScope": false
673
683
  },
674
684
  "./src/index.tsx": {
675
- "version": "0038fa29315665b5ed197940e2bf8a58ab1cf98d1d355920907ae0a9f076e805",
676
- "signature": "31fb4175a7d99c3fade724e5b4085978455d4e71cd64d4581181410b98366d2b",
685
+ "version": "e7033daf7518ad0bee73efedaaf6210f2a356bc984fcd2e92ef92a8671bb79c9",
686
+ "signature": "280628cb5b434821e3fb27721ecfb6d348b6aa9eea0e28fd5bee326a9444ed34",
677
687
  "affectsGlobalScope": false
678
688
  },
679
689
  "./src/__unpublished__/external-types.d.ts": {
@@ -1007,8 +1017,8 @@
1007
1017
  "affectsGlobalScope": false
1008
1018
  },
1009
1019
  "../../node_modules/@types/fs-extra/index.d.ts": {
1010
- "version": "ed19da84b7dbf00952ad0b98ce5c194f1903bcf7c94d8103e8e0d63b271543ae",
1011
- "signature": "ed19da84b7dbf00952ad0b98ce5c194f1903bcf7c94d8103e8e0d63b271543ae",
1020
+ "version": "6435575b4feae200831d37df9f871de6e695c64d3148611fe1b4d714d648ea24",
1021
+ "signature": "6435575b4feae200831d37df9f871de6e695c64d3148611fe1b4d714d648ea24",
1012
1022
  "affectsGlobalScope": false
1013
1023
  },
1014
1024
  "../../node_modules/@types/geojson/index.d.ts": {
@@ -1577,8 +1587,8 @@
1577
1587
  "affectsGlobalScope": false
1578
1588
  },
1579
1589
  "../../node_modules/@types/json-stable-stringify/index.d.ts": {
1580
- "version": "13cc3979e1f548aacaa23911f2d6e69c1a2999266c4a1952806de1e9593bdaaa",
1581
- "signature": "13cc3979e1f548aacaa23911f2d6e69c1a2999266c4a1952806de1e9593bdaaa",
1590
+ "version": "626520302b2c8880e9eaa3a6a12022cc8b577a32e4d903aef85e3dd275063da4",
1591
+ "signature": "626520302b2c8880e9eaa3a6a12022cc8b577a32e4d903aef85e3dd275063da4",
1582
1592
  "affectsGlobalScope": false
1583
1593
  },
1584
1594
  "../../node_modules/@types/json5/index.d.ts": {
@@ -1586,26 +1596,6 @@
1586
1596
  "signature": "96d14f21b7652903852eef49379d04dbda28c16ed36468f8c9fa08f7c14c9538",
1587
1597
  "affectsGlobalScope": false
1588
1598
  },
1589
- "../../node_modules/@types/mapbox-gl/index.d.ts": {
1590
- "version": "a49c26a7bad73494e987a795709e298223800407fa4e5c40c28539f752eb32ad",
1591
- "signature": "a49c26a7bad73494e987a795709e298223800407fa4e5c40c28539f752eb32ad",
1592
- "affectsGlobalScope": false
1593
- },
1594
- "../../node_modules/@types/mapbox__point-geometry/index.d.ts": {
1595
- "version": "e86cd9c6c99834f8591ed72f08e4ca31570296f081206d0168f58f032cec5b58",
1596
- "signature": "e86cd9c6c99834f8591ed72f08e4ca31570296f081206d0168f58f032cec5b58",
1597
- "affectsGlobalScope": false
1598
- },
1599
- "../../node_modules/@types/pbf/index.d.ts": {
1600
- "version": "2a856615ecd0af49997dfbb38cf94fd787d529062a2e96ce26b84432e61d785d",
1601
- "signature": "2a856615ecd0af49997dfbb38cf94fd787d529062a2e96ce26b84432e61d785d",
1602
- "affectsGlobalScope": false
1603
- },
1604
- "../../node_modules/@types/mapbox__vector-tile/index.d.ts": {
1605
- "version": "ab438f22fa7748112b6b9744b992ab6049d2fa6f46f011c145ff9c90e533856a",
1606
- "signature": "ab438f22fa7748112b6b9744b992ab6049d2fa6f46f011c145ff9c90e533856a",
1607
- "affectsGlobalScope": false
1608
- },
1609
1599
  "../../node_modules/@types/mdast/index.d.ts": {
1610
1600
  "version": "9a6d65d77455efaaaeff945bea30c38b8fe0922b807ba45cd23792392f1bfe76",
1611
1601
  "signature": "9a6d65d77455efaaaeff945bea30c38b8fe0922b807ba45cd23792392f1bfe76",
@@ -2020,6 +2010,9 @@
2020
2010
  "../../node_modules/@formatjs/ecma402-abstract/index.d.ts",
2021
2011
  "../../node_modules/@formatjs/intl/src/types.d.ts"
2022
2012
  ],
2013
+ "../../node_modules/@styled-icons/boxicons-regular/Transfer/Transfer.d.ts": [
2014
+ "../../node_modules/@styled-icons/styled-icon/index.d.ts"
2015
+ ],
2023
2016
  "../../node_modules/@styled-icons/fa-solid/CalendarAlt/CalendarAlt.d.ts": [
2024
2017
  "../../node_modules/@styled-icons/styled-icon/index.d.ts"
2025
2018
  ],
@@ -2238,14 +2231,6 @@
2238
2231
  "../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts": [
2239
2232
  "../../node_modules/@types/jest/node_modules/pretty-format/build/types.d.ts"
2240
2233
  ],
2241
- "../../node_modules/@types/mapbox-gl/index.d.ts": [
2242
- "../../node_modules/@types/geojson/index.d.ts"
2243
- ],
2244
- "../../node_modules/@types/mapbox__vector-tile/index.d.ts": [
2245
- "../../node_modules/@types/geojson/index.d.ts",
2246
- "../../node_modules/@types/mapbox__point-geometry/index.d.ts",
2247
- "../../node_modules/@types/pbf/index.d.ts"
2248
- ],
2249
2234
  "../../node_modules/@types/mdast/index.d.ts": [
2250
2235
  "../../node_modules/@types/unist/index.d.ts"
2251
2236
  ],
@@ -3009,12 +2994,16 @@
3009
2994
  "./src/__unpublished__/external-types.d.ts": [
3010
2995
  "../../node_modules/@types/react/index.d.ts"
3011
2996
  ],
3012
- "./src/fare-detail.tsx": [
2997
+ "./src/fare-table.tsx": [
2998
+ "../../node_modules/@styled-icons/boxicons-regular/Transfer/Transfer.d.ts",
2999
+ "../../node_modules/@types/flat/index.d.ts",
3013
3000
  "../../node_modules/@types/react/index.d.ts",
3014
3001
  "../../node_modules/@types/styled-components/index.d.ts",
3015
3002
  "../../node_modules/react-intl/index.d.ts",
3016
3003
  "../types/lib/index.d.ts",
3017
- "./src/types.ts"
3004
+ "./src/__unpublished__/messages.d.ts",
3005
+ "./src/types.ts",
3006
+ "./src/utils.tsx"
3018
3007
  ],
3019
3008
  "./src/index.tsx": [
3020
3009
  "../../node_modules/@styled-icons/fa-solid/CalendarAlt/CalendarAlt.d.ts",
@@ -3029,10 +3018,11 @@
3029
3018
  "../types/lib/index.d.ts",
3030
3019
  "./node_modules/@opentripplanner/core-utils/lib/index.d.ts",
3031
3020
  "./src/__unpublished__/messages.d.ts",
3032
- "./src/fare-detail.tsx",
3021
+ "./src/fare-table.tsx",
3033
3022
  "./src/styled.ts",
3034
3023
  "./src/trip-detail.tsx",
3035
- "./src/types.ts"
3024
+ "./src/types.ts",
3025
+ "./src/utils.tsx"
3036
3026
  ],
3037
3027
  "./src/styled.ts": [
3038
3028
  "../../node_modules/@types/styled-components/index.d.ts"
@@ -3048,6 +3038,10 @@
3048
3038
  "../../node_modules/@types/react/index.d.ts",
3049
3039
  "../types/lib/index.d.ts"
3050
3040
  ],
3041
+ "./src/utils.tsx": [
3042
+ "../../node_modules/@types/react/index.d.ts",
3043
+ "../../node_modules/react-intl/index.d.ts"
3044
+ ],
3051
3045
  "../types/lib/index.d.ts": [
3052
3046
  "../../node_modules/@types/react/index.d.ts"
3053
3047
  ]
@@ -3229,6 +3223,9 @@
3229
3223
  "../../node_modules/@formatjs/ecma402-abstract/index.d.ts",
3230
3224
  "../../node_modules/@formatjs/intl/src/types.d.ts"
3231
3225
  ],
3226
+ "../../node_modules/@styled-icons/boxicons-regular/Transfer/Transfer.d.ts": [
3227
+ "../../node_modules/@styled-icons/styled-icon/index.d.ts"
3228
+ ],
3232
3229
  "../../node_modules/@styled-icons/fa-solid/CalendarAlt/CalendarAlt.d.ts": [
3233
3230
  "../../node_modules/@styled-icons/styled-icon/index.d.ts"
3234
3231
  ],
@@ -3447,14 +3444,6 @@
3447
3444
  "../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts": [
3448
3445
  "../../node_modules/@types/jest/node_modules/pretty-format/build/types.d.ts"
3449
3446
  ],
3450
- "../../node_modules/@types/mapbox-gl/index.d.ts": [
3451
- "../../node_modules/@types/geojson/index.d.ts"
3452
- ],
3453
- "../../node_modules/@types/mapbox__vector-tile/index.d.ts": [
3454
- "../../node_modules/@types/geojson/index.d.ts",
3455
- "../../node_modules/@types/mapbox__point-geometry/index.d.ts",
3456
- "../../node_modules/@types/pbf/index.d.ts"
3457
- ],
3458
3447
  "../../node_modules/@types/mdast/index.d.ts": [
3459
3448
  "../../node_modules/@types/unist/index.d.ts"
3460
3449
  ],
@@ -4218,7 +4207,7 @@
4218
4207
  "./src/__unpublished__/external-types.d.ts": [
4219
4208
  "../../node_modules/@types/react/index.d.ts"
4220
4209
  ],
4221
- "./src/fare-detail.tsx": [
4210
+ "./src/fare-table.tsx": [
4222
4211
  "./src/types.ts"
4223
4212
  ],
4224
4213
  "./src/index.tsx": [
@@ -4236,6 +4225,9 @@
4236
4225
  "../../node_modules/@types/react/index.d.ts",
4237
4226
  "../types/lib/index.d.ts"
4238
4227
  ],
4228
+ "./src/utils.tsx": [
4229
+ "../../node_modules/@types/react/index.d.ts"
4230
+ ],
4239
4231
  "../types/lib/index.d.ts": [
4240
4232
  "../../node_modules/@types/react/index.d.ts"
4241
4233
  ]
@@ -4299,6 +4291,7 @@
4299
4291
  "../../node_modules/@formatjs/intl/src/relativeTime.d.ts",
4300
4292
  "../../node_modules/@formatjs/intl/src/types.d.ts",
4301
4293
  "../../node_modules/@formatjs/intl/src/utils.d.ts",
4294
+ "../../node_modules/@styled-icons/boxicons-regular/Transfer/Transfer.d.ts",
4302
4295
  "../../node_modules/@styled-icons/fa-solid/CalendarAlt/CalendarAlt.d.ts",
4303
4296
  "../../node_modules/@styled-icons/fa-solid/HandPaper/HandPaper.d.ts",
4304
4297
  "../../node_modules/@styled-icons/fa-solid/Heartbeat/Heartbeat.d.ts",
@@ -4361,9 +4354,6 @@
4361
4354
  "../../node_modules/@types/json-schema/index.d.ts",
4362
4355
  "../../node_modules/@types/json-stable-stringify/index.d.ts",
4363
4356
  "../../node_modules/@types/json5/index.d.ts",
4364
- "../../node_modules/@types/mapbox-gl/index.d.ts",
4365
- "../../node_modules/@types/mapbox__point-geometry/index.d.ts",
4366
- "../../node_modules/@types/mapbox__vector-tile/index.d.ts",
4367
4357
  "../../node_modules/@types/mdast/index.d.ts",
4368
4358
  "../../node_modules/@types/minimatch/index.d.ts",
4369
4359
  "../../node_modules/@types/minimist/index.d.ts",
@@ -4427,7 +4417,6 @@
4427
4417
  "../../node_modules/@types/overlayscrollbars/index.d.ts",
4428
4418
  "../../node_modules/@types/parse-json/index.d.ts",
4429
4419
  "../../node_modules/@types/parse5/index.d.ts",
4430
- "../../node_modules/@types/pbf/index.d.ts",
4431
4420
  "../../node_modules/@types/pixelmatch/index.d.ts",
4432
4421
  "../../node_modules/@types/prettier/index.d.ts",
4433
4422
  "../../node_modules/@types/pretty-hrtime/index.d.ts",
@@ -4600,11 +4589,12 @@
4600
4589
  "./node_modules/@opentripplanner/core-utils/lib/ui.d.ts",
4601
4590
  "./src/__unpublished__/external-types.d.ts",
4602
4591
  "./src/__unpublished__/messages.d.ts",
4603
- "./src/fare-detail.tsx",
4592
+ "./src/fare-table.tsx",
4604
4593
  "./src/index.tsx",
4605
4594
  "./src/styled.ts",
4606
4595
  "./src/trip-detail.tsx",
4607
4596
  "./src/types.ts",
4597
+ "./src/utils.tsx",
4608
4598
  "../types/lib/index.d.ts"
4609
4599
  ]
4610
4600
  },
@@ -1,111 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
-
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
-
7
- /* eslint-disable import/prefer-default-export */
8
- import React from "react";
9
- import styled from "styled-components";
10
- import { FormattedNumber } from "react-intl";
11
- var TableHeader = styled.thead.withConfig({
12
- displayName: "fare-detail__TableHeader",
13
- componentId: "sc-9025ni-0"
14
- })(["th{min-width:5ch;padding:0.75em 1.5em;text-align:center;}th:nth-of-type(2n + 1){background:#cccccc22;}th.main{color:#ffffffcc;background:#333333;}"]);
15
- var TotalRow = styled.tr.withConfig({
16
- displayName: "fare-detail__TotalRow",
17
- componentId: "sc-9025ni-1"
18
- })(["border-top:2px solid #333;font-weight:600;"]);
19
- var Table = styled.table.withConfig({
20
- displayName: "fare-detail__Table",
21
- componentId: "sc-9025ni-2"
22
- })(["border-collapse:collapse;display:block;font-family:sans-serif;margin:-8px;margin-bottom:16px;padding:0;td{text-align:right;}td:nth-of-type(2n + 1){background:#cccccc22;}td.no-zebra{background:transparent;}th:first-of-type{height:40px;}"]);
23
-
24
- var FareTypeTable = function FareTypeTable(props) {
25
- var header = props.header,
26
- fareTotals = props.fareTotals,
27
- cols = props.cols,
28
- legs = props.legs;
29
- return /*#__PURE__*/React.createElement(Table, null, /*#__PURE__*/React.createElement(TableHeader, null, /*#__PURE__*/React.createElement("th", {
30
- className: "main"
31
- }, header), cols.map(function (col) {
32
- return /*#__PURE__*/React.createElement("th", {
33
- key: col.header
34
- }, col.header);
35
- })), legs.map(function (leg, index) {
36
- return /*#__PURE__*/React.createElement("tr", {
37
- key: index
38
- }, /*#__PURE__*/React.createElement("td", {
39
- className: "no-zebra"
40
- }, leg.routeShortName), cols.map(function (col) {
41
- var _fare$price, _legs$0$fares, _legs$0$fares$col$key, _legs$0$fares$col$key2;
42
-
43
- var fare = leg.fares[col.key];
44
- return /*#__PURE__*/React.createElement("td", {
45
- key: col.key
46
- }, /*#__PURE__*/React.createElement(FormattedNumber, {
47
- value: (fare === null || fare === void 0 ? void 0 : (_fare$price = fare.price) === null || _fare$price === void 0 ? void 0 : _fare$price.cents) / 100 || 0 // This isn't a "real" style prop
48
- // eslint-disable-next-line react/style-prop-object
49
- ,
50
- style: "currency",
51
- currency: (fare === null || fare === void 0 ? void 0 : fare.price.currency.currencyCode) || ( // This is how the itinerary-wide currency code is calculated on the back-end
52
- legs === null || legs === void 0 ? void 0 : (_legs$0$fares = legs[0].fares) === null || _legs$0$fares === void 0 ? void 0 : (_legs$0$fares$col$key = _legs$0$fares[col.key]) === null || _legs$0$fares$col$key === void 0 ? void 0 : (_legs$0$fares$col$key2 = _legs$0$fares$col$key.price) === null || _legs$0$fares$col$key2 === void 0 ? void 0 : _legs$0$fares$col$key2.currency.currencyCode),
53
- currencyDisplay: "narrowSymbol"
54
- }));
55
- }));
56
- }), /*#__PURE__*/React.createElement(TotalRow, null, /*#__PURE__*/React.createElement("td", {
57
- className: "no-zebra"
58
- }, "Total"), cols.map(function (col) {
59
- var _fare$currency;
60
-
61
- var fare = fareTotals[col.key];
62
- return /*#__PURE__*/React.createElement("td", {
63
- key: col.key
64
- }, /*#__PURE__*/React.createElement(FormattedNumber, {
65
- value: ((fare === null || fare === void 0 ? void 0 : fare.cents) || 0) / 100 // This isn't a "real" style prop
66
- // eslint-disable-next-line react/style-prop-object
67
- ,
68
- style: "currency",
69
- currency: fare === null || fare === void 0 ? void 0 : (_fare$currency = fare.currency) === null || _fare$currency === void 0 ? void 0 : _fare$currency.currencyCode,
70
- currencyDisplay: "narrowSymbol"
71
- }));
72
- })));
73
- }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
74
-
75
-
76
- export var FareDetails = function FareDetails(props) {
77
- var legs = props.legs,
78
- transitFares = props.transitFares,
79
- layout = props.layout;
80
- var fareKeys = Object.keys(transitFares.details);
81
- var legsWithFares = legs.map(function (leg, index) {
82
- var fares = fareKeys.reduce(function (prev, key) {
83
- var _transitFares$details;
84
-
85
- var fareForKey = (_transitFares$details = transitFares.details[key]) === null || _transitFares$details === void 0 ? void 0 : _transitFares$details.find(function (detail) {
86
- return detail.legIndex === index;
87
- });
88
-
89
- if (fareForKey) {
90
- prev[key] = fareForKey;
91
- }
92
-
93
- return prev;
94
- }, {});
95
- return _objectSpread(_objectSpread({}, leg), {}, {
96
- fares: fares
97
- });
98
- }).filter(function (leg) {
99
- return leg.transitLeg;
100
- });
101
- return /*#__PURE__*/React.createElement("div", null, layout.map(function (config) {
102
- return /*#__PURE__*/React.createElement(FareTypeTable, {
103
- header: config.header,
104
- cols: config.cols,
105
- key: config.header,
106
- legs: legsWithFares,
107
- fareTotals: transitFares.fare
108
- });
109
- }));
110
- };
111
- //# sourceMappingURL=fare-detail.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/fare-detail.tsx"],"names":["React","styled","FormattedNumber","TableHeader","thead","TotalRow","tr","Table","table","FareTypeTable","props","header","fareTotals","cols","legs","map","col","leg","index","routeShortName","fare","fares","key","price","cents","currency","currencyCode","FareDetails","transitFares","layout","fareKeys","Object","keys","details","legsWithFares","reduce","prev","fareForKey","find","detail","legIndex","filter","transitLeg","config"],"mappings":";;;;;;AAAA;AAGA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,MAAP,MAAmB,mBAAnB;AACA,SAASC,eAAT,QAAgC,YAAhC;AAaA,IAAMC,WAAW,GAAGF,MAAM,CAACG,KAAV;AAAA;AAAA;AAAA,0JAAjB;AAeA,IAAMC,QAAQ,GAAGJ,MAAM,CAACK,EAAV;AAAA;AAAA;AAAA,kDAAd;AAKA,IAAMC,KAAK,GAAGN,MAAM,CAACO,KAAV;AAAA;AAAA;AAAA,mPAAX;;AAuBA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAA4C;AAChE,MAAQC,MAAR,GAA2CD,KAA3C,CAAQC,MAAR;AAAA,MAAgBC,UAAhB,GAA2CF,KAA3C,CAAgBE,UAAhB;AAAA,MAA4BC,IAA5B,GAA2CH,KAA3C,CAA4BG,IAA5B;AAAA,MAAkCC,IAAlC,GAA2CJ,KAA3C,CAAkCI,IAAlC;AACA,sBACE,oBAAC,KAAD,qBACE,oBAAC,WAAD,qBACE;AAAI,IAAA,SAAS,EAAC;AAAd,KAAsBH,MAAtB,CADF,EAEGE,IAAI,CAACE,GAAL,CAAS,UAAAC,GAAG;AAAA,wBACX;AAAI,MAAA,GAAG,EAAEA,GAAG,CAACL;AAAb,OAAsBK,GAAG,CAACL,MAA1B,CADW;AAAA,GAAZ,CAFH,CADF,EAOGG,IAAI,CAACC,GAAL,CAAS,UAACE,GAAD,EAAMC,KAAN;AAAA,wBACR;AAAI,MAAA,GAAG,EAAEA;AAAT,oBACE;AAAI,MAAA,SAAS,EAAC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C,aAAD;AACE,MAAA,MAAM,EAAEA,MAAM,CAAChC,MADjB;AAEE,MAAA,IAAI,EAAEgC,MAAM,CAAC9B,IAFf;AAGE,MAAA,GAAG,EAAE8B,MAAM,CAAChC,MAHd;AAIE,MAAA,IAAI,EAAEuB,aAJR;AAKE,MAAA,UAAU,EAAEN,YAAY,CAACR;AAL3B,MADgB;AAAA,GAAjB,CADH,CADF;AAaD,CAnCM","sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport { Leg, Money } from \"@opentripplanner/types\";\n\nimport React from \"react\";\nimport styled from \"styled-components\";\nimport { FormattedNumber } from \"react-intl\";\nimport { FareDetailsProps } from \"./types\";\n\ninterface FareTypeTableProps {\n header: string;\n cols: {\n key: string;\n header: string;\n }[];\n legs: (Leg & { fares: { [key: string]: { price: Money } } })[];\n fareTotals: { [fareKey: string]: Money };\n}\n\nconst TableHeader = styled.thead`\n th {\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 color: #ffffffcc;\n background: #333333;\n }\n`;\n\nconst TotalRow = styled.tr`\n border-top: 2px solid #333;\n font-weight: 600;\n`;\n\nconst Table = styled.table`\n border-collapse: collapse;\n display: block;\n font-family: sans-serif;\n margin: -8px;\n /* This line can not be sorted alphabetically, because it must come after the margin rule */\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: transparent;\n }\n th:first-of-type {\n height: 40px;\n }\n`;\n\nconst FareTypeTable = (props: FareTypeTableProps): JSX.Element => {\n const { header, fareTotals, cols, legs } = props;\n return (\n <Table>\n <TableHeader>\n <th className=\"main\">{header}</th>\n {cols.map(col => (\n <th key={col.header}>{col.header}</th>\n ))}\n </TableHeader>\n {legs.map((leg, index) => (\n <tr key={index}>\n <td className=\"no-zebra\">{leg.routeShortName}</td>\n {cols.map(col => {\n const fare = leg.fares[col.key];\n return (\n <td key={col.key}>\n <FormattedNumber\n value={fare?.price?.cents / 100 || 0}\n // This isn't a \"real\" style prop\n // eslint-disable-next-line react/style-prop-object\n style=\"currency\"\n currency={\n fare?.price.currency.currencyCode ||\n // This is how the itinerary-wide currency code is calculated on the back-end\n legs?.[0].fares?.[col.key]?.price?.currency.currencyCode\n }\n currencyDisplay=\"narrowSymbol\"\n />\n </td>\n );\n })}\n </tr>\n ))}\n <TotalRow>\n <td className=\"no-zebra\">Total</td>\n {cols.map(col => {\n const fare = fareTotals[col.key];\n return (\n <td key={col.key}>\n <FormattedNumber\n value={(fare?.cents || 0) / 100}\n // This isn't a \"real\" style prop\n // eslint-disable-next-line react/style-prop-object\n style=\"currency\"\n currency={fare?.currency?.currencyCode}\n currencyDisplay=\"narrowSymbol\"\n />\n </td>\n );\n })}\n </TotalRow>\n </Table>\n );\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const FareDetails = (props: FareDetailsProps): JSX.Element => {\n const { legs, transitFares, layout } = props;\n const fareKeys = Object.keys(transitFares.details);\n\n const legsWithFares = legs\n .map((leg, index) => {\n const fares = fareKeys.reduce((prev, key) => {\n const fareForKey = transitFares.details[key]?.find(\n detail => detail.legIndex === index\n );\n if (fareForKey) {\n prev[key] = fareForKey;\n }\n return prev;\n }, {});\n return {\n ...leg,\n fares\n };\n })\n .filter(leg => leg.transitLeg);\n\n return (\n <div>\n {layout.map(config => (\n <FareTypeTable\n header={config.header}\n cols={config.cols}\n key={config.header}\n legs={legsWithFares}\n fareTotals={transitFares.fare}\n />\n ))}\n </div>\n );\n};\n"],"file":"fare-detail.js"}
@@ -1,3 +0,0 @@
1
- import { FareDetailsProps } from "./types";
2
- export declare const FareDetails: (props: FareDetailsProps) => JSX.Element;
3
- //# sourceMappingURL=fare-detail.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fare-detail.d.ts","sourceRoot":"","sources":["../src/fare-detail.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAgH3C,eAAO,MAAM,WAAW,UAAW,gBAAgB,KAAG,WAmCrD,CAAC"}
@@ -1,115 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.FareDetails = void 0;
9
-
10
- var _react = _interopRequireDefault(require("react"));
11
-
12
- var _styledComponents = _interopRequireDefault(require("styled-components"));
13
-
14
- var _reactIntl = require("react-intl");
15
-
16
- /* eslint-disable import/prefer-default-export */
17
- const TableHeader = _styledComponents.default.thead.withConfig({
18
- displayName: "fare-detail__TableHeader",
19
- componentId: "sc-9025ni-0"
20
- })(["th{min-width:5ch;padding:0.75em 1.5em;text-align:center;}th:nth-of-type(2n + 1){background:#cccccc22;}th.main{color:#ffffffcc;background:#333333;}"]);
21
-
22
- const TotalRow = _styledComponents.default.tr.withConfig({
23
- displayName: "fare-detail__TotalRow",
24
- componentId: "sc-9025ni-1"
25
- })(["border-top:2px solid #333;font-weight:600;"]);
26
-
27
- const Table = _styledComponents.default.table.withConfig({
28
- displayName: "fare-detail__Table",
29
- componentId: "sc-9025ni-2"
30
- })(["border-collapse:collapse;display:block;font-family:sans-serif;margin:-8px;margin-bottom:16px;padding:0;td{text-align:right;}td:nth-of-type(2n + 1){background:#cccccc22;}td.no-zebra{background:transparent;}th:first-of-type{height:40px;}"]);
31
-
32
- const FareTypeTable = props => {
33
- const {
34
- header,
35
- fareTotals,
36
- cols,
37
- legs
38
- } = props;
39
- return /*#__PURE__*/_react.default.createElement(Table, null, /*#__PURE__*/_react.default.createElement(TableHeader, null, /*#__PURE__*/_react.default.createElement("th", {
40
- className: "main"
41
- }, header), cols.map(col => /*#__PURE__*/_react.default.createElement("th", {
42
- key: col.header
43
- }, col.header))), legs.map((leg, index) => /*#__PURE__*/_react.default.createElement("tr", {
44
- key: index
45
- }, /*#__PURE__*/_react.default.createElement("td", {
46
- className: "no-zebra"
47
- }, leg.routeShortName), cols.map(col => {
48
- var _fare$price, _legs$0$fares, _legs$0$fares$col$key, _legs$0$fares$col$key2;
49
-
50
- const fare = leg.fares[col.key];
51
- return /*#__PURE__*/_react.default.createElement("td", {
52
- key: col.key
53
- }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedNumber, {
54
- value: (fare === null || fare === void 0 ? void 0 : (_fare$price = fare.price) === null || _fare$price === void 0 ? void 0 : _fare$price.cents) / 100 || 0 // This isn't a "real" style prop
55
- // eslint-disable-next-line react/style-prop-object
56
- ,
57
- style: "currency",
58
- currency: (fare === null || fare === void 0 ? void 0 : fare.price.currency.currencyCode) || ( // This is how the itinerary-wide currency code is calculated on the back-end
59
- legs === null || legs === void 0 ? void 0 : (_legs$0$fares = legs[0].fares) === null || _legs$0$fares === void 0 ? void 0 : (_legs$0$fares$col$key = _legs$0$fares[col.key]) === null || _legs$0$fares$col$key === void 0 ? void 0 : (_legs$0$fares$col$key2 = _legs$0$fares$col$key.price) === null || _legs$0$fares$col$key2 === void 0 ? void 0 : _legs$0$fares$col$key2.currency.currencyCode),
60
- currencyDisplay: "narrowSymbol"
61
- }));
62
- }))), /*#__PURE__*/_react.default.createElement(TotalRow, null, /*#__PURE__*/_react.default.createElement("td", {
63
- className: "no-zebra"
64
- }, "Total"), cols.map(col => {
65
- var _fare$currency;
66
-
67
- const fare = fareTotals[col.key];
68
- return /*#__PURE__*/_react.default.createElement("td", {
69
- key: col.key
70
- }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedNumber, {
71
- value: ((fare === null || fare === void 0 ? void 0 : fare.cents) || 0) / 100 // This isn't a "real" style prop
72
- // eslint-disable-next-line react/style-prop-object
73
- ,
74
- style: "currency",
75
- currency: fare === null || fare === void 0 ? void 0 : (_fare$currency = fare.currency) === null || _fare$currency === void 0 ? void 0 : _fare$currency.currencyCode,
76
- currencyDisplay: "narrowSymbol"
77
- }));
78
- })));
79
- }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
80
-
81
-
82
- const FareDetails = props => {
83
- const {
84
- legs,
85
- transitFares,
86
- layout
87
- } = props;
88
- const fareKeys = Object.keys(transitFares.details);
89
- const legsWithFares = legs.map((leg, index) => {
90
- const fares = fareKeys.reduce((prev, key) => {
91
- var _transitFares$details;
92
-
93
- const fareForKey = (_transitFares$details = transitFares.details[key]) === null || _transitFares$details === void 0 ? void 0 : _transitFares$details.find(detail => detail.legIndex === index);
94
-
95
- if (fareForKey) {
96
- prev[key] = fareForKey;
97
- }
98
-
99
- return prev;
100
- }, {});
101
- return { ...leg,
102
- fares
103
- };
104
- }).filter(leg => leg.transitLeg);
105
- return /*#__PURE__*/_react.default.createElement("div", null, layout.map(config => /*#__PURE__*/_react.default.createElement(FareTypeTable, {
106
- header: config.header,
107
- cols: config.cols,
108
- key: config.header,
109
- legs: legsWithFares,
110
- fareTotals: transitFares.fare
111
- })));
112
- };
113
-
114
- exports.FareDetails = FareDetails;
115
- //# sourceMappingURL=fare-detail.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/fare-detail.tsx"],"names":["TableHeader","styled","thead","TotalRow","tr","Table","table","FareTypeTable","props","header","fareTotals","cols","legs","map","col","leg","index","routeShortName","fare","fares","key","price","cents","currency","currencyCode","FareDetails","transitFares","layout","fareKeys","Object","keys","details","legsWithFares","reduce","prev","fareForKey","find","detail","legIndex","filter","transitLeg","config"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AAkBA,MAAMA,WAAW,GAAGC,0BAAOC,KAAV;AAAA;AAAA;AAAA,0JAAjB;;AAeA,MAAMC,QAAQ,GAAGF,0BAAOG,EAAV;AAAA;AAAA;AAAA,kDAAd;;AAKA,MAAMC,KAAK,GAAGJ,0BAAOK,KAAV;AAAA;AAAA;AAAA,mPAAX;;AAuBA,MAAMC,aAAa,GAAIC,KAAD,IAA4C;AAChE,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,UAAV;AAAsBC,I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AOD,IAAP;AACD,KARa,EAQX,EARW,CAAd;AASA,WAAO,EACL,GAAGnB,GADE;AAELI,MAAAA;AAFK,KAAP;AAID,GAfmB,EAgBnBoB,MAhBmB,CAgBZxB,GAAG,IAAIA,GAAG,CAACyB,UAhBC,CAAtB;AAkBA,sBACE,0CACGb,MAAM,CAACd,GAAP,CAAW4B,MAAM,iBAChB,6BAAC,aAAD;AACE,IAAA,MAAM,EAAEA,MAAM,CAAChC,MADjB;AAEE,IAAA,IAAI,EAAEgC,MAAM,CAAC9B,IAFf;AAGE,IAAA,GAAG,EAAE8B,MAAM,CAAChC,MAHd;AAIE,IAAA,IAAI,EAAEuB,aAJR;AAKE,IAAA,UAAU,EAAEN,YAAY,CAACR;AAL3B,IADD,CADH,CADF;AAaD,CAnCM","sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport { Leg, Money } from \"@opentripplanner/types\";\n\nimport React from \"react\";\nimport styled from \"styled-components\";\nimport { FormattedNumber } from \"react-intl\";\nimport { FareDetailsProps } from \"./types\";\n\ninterface FareTypeTableProps {\n header: string;\n cols: {\n key: string;\n header: string;\n }[];\n legs: (Leg & { fares: { [key: string]: { price: Money } } })[];\n fareTotals: { [fareKey: string]: Money };\n}\n\nconst TableHeader = styled.thead`\n th {\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 color: #ffffffcc;\n background: #333333;\n }\n`;\n\nconst TotalRow = styled.tr`\n border-top: 2px solid #333;\n font-weight: 600;\n`;\n\nconst Table = styled.table`\n border-collapse: collapse;\n display: block;\n font-family: sans-serif;\n margin: -8px;\n /* This line can not be sorted alphabetically, because it must come after the margin rule */\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: transparent;\n }\n th:first-of-type {\n height: 40px;\n }\n`;\n\nconst FareTypeTable = (props: FareTypeTableProps): JSX.Element => {\n const { header, fareTotals, cols, legs } = props;\n return (\n <Table>\n <TableHeader>\n <th className=\"main\">{header}</th>\n {cols.map(col => (\n <th key={col.header}>{col.header}</th>\n ))}\n </TableHeader>\n {legs.map((leg, index) => (\n <tr key={index}>\n <td className=\"no-zebra\">{leg.routeShortName}</td>\n {cols.map(col => {\n const fare = leg.fares[col.key];\n return (\n <td key={col.key}>\n <FormattedNumber\n value={fare?.price?.cents / 100 || 0}\n // This isn't a \"real\" style prop\n // eslint-disable-next-line react/style-prop-object\n style=\"currency\"\n currency={\n fare?.price.currency.currencyCode ||\n // This is how the itinerary-wide currency code is calculated on the back-end\n legs?.[0].fares?.[col.key]?.price?.currency.currencyCode\n }\n currencyDisplay=\"narrowSymbol\"\n />\n </td>\n );\n })}\n </tr>\n ))}\n <TotalRow>\n <td className=\"no-zebra\">Total</td>\n {cols.map(col => {\n const fare = fareTotals[col.key];\n return (\n <td key={col.key}>\n <FormattedNumber\n value={(fare?.cents || 0) / 100}\n // This isn't a \"real\" style prop\n // eslint-disable-next-line react/style-prop-object\n style=\"currency\"\n currency={fare?.currency?.currencyCode}\n currencyDisplay=\"narrowSymbol\"\n />\n </td>\n );\n })}\n </TotalRow>\n </Table>\n );\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const FareDetails = (props: FareDetailsProps): JSX.Element => {\n const { legs, transitFares, layout } = props;\n const fareKeys = Object.keys(transitFares.details);\n\n const legsWithFares = legs\n .map((leg, index) => {\n const fares = fareKeys.reduce((prev, key) => {\n const fareForKey = transitFares.details[key]?.find(\n detail => detail.legIndex === index\n );\n if (fareForKey) {\n prev[key] = fareForKey;\n }\n return prev;\n }, {});\n return {\n ...leg,\n fares\n };\n })\n .filter(leg => leg.transitLeg);\n\n return (\n <div>\n {layout.map(config => (\n <FareTypeTable\n header={config.header}\n cols={config.cols}\n key={config.header}\n legs={legsWithFares}\n fareTotals={transitFares.fare}\n />\n ))}\n </div>\n );\n};\n"],"file":"fare-detail.js"}