@opentripplanner/trip-details 9.0.5 → 9.0.6
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/README.md +3 -0
- package/lib/components/departure-date.js +43 -18
- package/lib/components/departure-date.js.map +1 -1
- package/lib/components/emissions.js +65 -30
- package/lib/components/emissions.js.map +1 -1
- package/lib/components/fares-v2-table.js +180 -142
- package/lib/components/fares-v2-table.js.map +1 -1
- package/lib/components/fares.js +125 -65
- package/lib/components/fares.js.map +1 -1
- package/lib/components/flex-booking-info.js +39 -28
- package/lib/components/flex-booking-info.js.map +1 -1
- package/lib/components/time-active.js +67 -33
- package/lib/components/time-active.js.map +1 -1
- package/lib/index.js +68 -26
- package/lib/index.js.map +1 -1
- package/lib/styled.js +94 -95
- package/lib/styled.js.map +1 -1
- package/lib/trip-detail.js +64 -38
- package/lib/trip-detail.js.map +1 -1
- package/lib/types.js +5 -1
- package/lib/types.js.map +1 -1
- package/lib/utils.js +26 -12
- package/lib/utils.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/lib/index.js
CHANGED
|
@@ -1,38 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "FaresV2Table", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _faresV2Table.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.Styled = void 0;
|
|
14
|
+
exports.TripDetails = TripDetails;
|
|
15
|
+
exports.default = void 0;
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
var _reactIntl = require("react-intl");
|
|
18
|
+
var _flat = require("flat");
|
|
19
|
+
var S = _interopRequireWildcard(require("./styled"));
|
|
20
|
+
exports.Styled = S;
|
|
21
|
+
var _flexBookingInfo = _interopRequireDefault(require("./components/flex-booking-info"));
|
|
22
|
+
var _faresV2Table = _interopRequireDefault(require("./components/fares-v2-table"));
|
|
23
|
+
var _emissions = _interopRequireDefault(require("./components/emissions"));
|
|
24
|
+
var _fares = _interopRequireDefault(require("./components/fares"));
|
|
25
|
+
var _timeActive = _interopRequireWildcard(require("./components/time-active"));
|
|
26
|
+
var _departureDate = _interopRequireDefault(require("./components/departure-date"));
|
|
27
|
+
var _enUS = _interopRequireDefault(require("../i18n/en-US.yml"));
|
|
28
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
29
|
// Load the default messages.
|
|
12
|
-
|
|
30
|
+
|
|
13
31
|
// HACK: We should flatten the messages loaded above because
|
|
14
32
|
// the YAML loaders behave differently between webpack and our version of jest:
|
|
15
33
|
// - the yaml loader for webpack returns a nested object,
|
|
16
34
|
// - the yaml loader for jest returns messages with flattened ids.
|
|
17
|
-
const defaultMessages = flatten(
|
|
35
|
+
const defaultMessages = (0, _flat.flatten)(_enUS.default);
|
|
18
36
|
function cn(className, arg1) {
|
|
19
|
-
|
|
37
|
+
return className ? `${className} ${arg1}` : arg1;
|
|
20
38
|
}
|
|
39
|
+
|
|
21
40
|
/**
|
|
22
41
|
* Renders trip details such as departure instructions, fare amount, and minutes active.
|
|
23
42
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
function TripDetails({
|
|
44
|
+
className = "",
|
|
45
|
+
co2Config,
|
|
46
|
+
defaultFareType,
|
|
47
|
+
DepartureDetails = null,
|
|
48
|
+
FareDetails = null,
|
|
49
|
+
itinerary,
|
|
50
|
+
showApproximateMinutesActive,
|
|
51
|
+
TimeActiveDetails = _timeActive.DefaultTimeActiveDetails
|
|
52
|
+
}) {
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(S.TripDetails, {
|
|
54
|
+
className: cn(className, "trip-details")
|
|
55
|
+
}, /*#__PURE__*/_react.default.createElement(S.TripDetailsHeader, {
|
|
56
|
+
id: "trip-details-header"
|
|
57
|
+
}, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
|
|
58
|
+
defaultMessage: defaultMessages["otpUi.TripDetails.title"],
|
|
59
|
+
description: "Title (heading) text of the component.",
|
|
60
|
+
id: "otpUi.TripDetails.title"
|
|
61
|
+
})), /*#__PURE__*/_react.default.createElement(S.TripDetailsBody, null, /*#__PURE__*/_react.default.createElement(_departureDate.default, {
|
|
62
|
+
itinerary: itinerary,
|
|
63
|
+
DepartureDetails: DepartureDetails
|
|
64
|
+
}), /*#__PURE__*/_react.default.createElement(_fares.default, {
|
|
65
|
+
itinerary: itinerary,
|
|
66
|
+
FareDetails: FareDetails,
|
|
67
|
+
defaultFareType: defaultFareType
|
|
68
|
+
}), /*#__PURE__*/_react.default.createElement(_timeActive.default, {
|
|
69
|
+
itinerary: itinerary,
|
|
70
|
+
TimeActiveDetails: TimeActiveDetails,
|
|
71
|
+
showApproximateMinutesActive: showApproximateMinutesActive
|
|
72
|
+
}), /*#__PURE__*/_react.default.createElement(_flexBookingInfo.default, {
|
|
73
|
+
itinerary: itinerary
|
|
74
|
+
}), /*#__PURE__*/_react.default.createElement(_emissions.default, {
|
|
75
|
+
itinerary: itinerary,
|
|
76
|
+
co2Config: co2Config
|
|
77
|
+
})));
|
|
34
78
|
}
|
|
35
|
-
|
|
36
|
-
// Rename styled components for export.
|
|
37
|
-
export { S as Styled, FaresV2Table };
|
|
79
|
+
var _default = exports.default = TripDetails; // Rename styled components for export.
|
|
38
80
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_reactIntl","_flat","S","_interopRequireWildcard","exports","Styled","_flexBookingInfo","_faresV2Table","_emissions","_fares","_timeActive","_departureDate","_enUS","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","defaultMessages","flatten","defaultEnglishMessages","cn","className","arg1","TripDetails","co2Config","defaultFareType","DepartureDetails","FareDetails","itinerary","showApproximateMinutesActive","TimeActiveDetails","DefaultTimeActiveDetails","createElement","TripDetailsHeader","id","FormattedMessage","defaultMessage","description","TripDetailsBody","_default"],"sources":["../src/index.tsx"],"sourcesContent":["import React, { ReactElement } from \"react\";\nimport { FormattedMessage } from \"react-intl\";\nimport { flatten } from \"flat\";\nimport * as S from \"./styled\";\nimport { TripDetailsProps } from \"./types\";\nimport FlexBookingInfo from \"./components/flex-booking-info\";\nimport FaresV2Table from \"./components/fares-v2-table\";\nimport Emissions from \"./components/emissions\";\nimport Fares from \"./components/fares\";\nimport TimeActive, { DefaultTimeActiveDetails } from \"./components/time-active\";\nimport DepartureDate from \"./components/departure-date\";\n\n// Load the default messages.\nimport defaultEnglishMessages from \"../i18n/en-US.yml\";\n\n// HACK: We should flatten the messages loaded above because\n// the YAML loaders behave differently between webpack and our version of jest:\n// - the yaml loader for webpack returns a nested object,\n// - the yaml loader for jest returns messages with flattened ids.\nconst defaultMessages: Record<string, string> = flatten(defaultEnglishMessages);\n\nfunction cn(className: string, arg1: string): string {\n return className ? `${className} ${arg1}` : arg1;\n}\n\n/**\n * Renders trip details such as departure instructions, fare amount, and minutes active.\n */\nexport function TripDetails({\n className = \"\",\n co2Config,\n defaultFareType,\n DepartureDetails = null,\n FareDetails = null,\n itinerary,\n showApproximateMinutesActive,\n TimeActiveDetails = DefaultTimeActiveDetails\n}: TripDetailsProps): ReactElement {\n return (\n <S.TripDetails className={cn(className, \"trip-details\")}>\n {/* this can be presentation as S.TripDetails is already labeled by this */}\n <S.TripDetailsHeader id=\"trip-details-header\">\n <FormattedMessage\n defaultMessage={defaultMessages[\"otpUi.TripDetails.title\"]}\n description=\"Title (heading) text of the component.\"\n id=\"otpUi.TripDetails.title\"\n />\n </S.TripDetailsHeader>\n\n <S.TripDetailsBody>\n <DepartureDate\n itinerary={itinerary}\n DepartureDetails={DepartureDetails}\n />\n <Fares\n itinerary={itinerary}\n FareDetails={FareDetails}\n defaultFareType={defaultFareType}\n />\n <TimeActive\n itinerary={itinerary}\n TimeActiveDetails={TimeActiveDetails}\n showApproximateMinutesActive={showApproximateMinutesActive}\n />\n <FlexBookingInfo itinerary={itinerary} />\n <Emissions itinerary={itinerary} co2Config={co2Config} />\n </S.TripDetailsBody>\n </S.TripDetails>\n );\n}\n\nexport default TripDetails;\n\n// Rename styled components for export.\nexport { S as Styled, FaresV2Table };\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,CAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAA8BK,OAAA,CAAAC,MAAA,GAAAH,CAAA;AAE9B,IAAAI,gBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,aAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,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AAAa,OAAU;IACToB,SAAS,EAAEA,SAAU;IACrBE,iBAAiB,EAAEA,iBAAkB;IACrCD,4BAA4B,EAAEA;EAA6B,CAC5D,CAAC,eACF/C,MAAA,CAAA0B,OAAA,CAAAwB,aAAA,CAACzC,gBAAA,CAAAiB,OAAe;IAACoB,SAAS,EAAEA;EAAU,CAAE,CAAC,eACzC9C,MAAA,CAAA0B,OAAA,CAAAwB,aAAA,CAACvC,UAAA,CAAAe,OAAS;IAACoB,SAAS,EAAEA,SAAU;IAACJ,SAAS,EAAEA;EAAU,CAAE,CACvC,CACN,CAAC;AAEpB;AAAC,IAAAe,QAAA,GAAAlD,OAAA,CAAAmB,OAAA,GAEce,WAAW,EAE1B","ignoreList":[]}
|
package/lib/styled.js
CHANGED
|
@@ -1,97 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export const InvisibleA11yCaption = styled.caption `
|
|
15
|
-
${InvisibleA11yStyles}
|
|
16
|
-
`;
|
|
17
|
-
const BaseButton = styled.button `
|
|
18
|
-
background: transparent;
|
|
19
|
-
border: 0;
|
|
20
|
-
cursor: pointer;
|
|
21
|
-
display: inline-block;
|
|
22
|
-
font-size: 14px;
|
|
23
|
-
font-weight: 400;
|
|
24
|
-
line-height: 1.42857143;
|
|
25
|
-
margin: 0;
|
|
26
|
-
padding: 0;
|
|
27
|
-
text-decoration: none;
|
|
28
|
-
touch-action: manipulation;
|
|
29
|
-
user-select: none;
|
|
30
|
-
vertical-align: middle;
|
|
31
|
-
white-space: nowrap;
|
|
32
|
-
`;
|
|
33
|
-
export const CO2Description = styled.span ``;
|
|
34
|
-
export const CO2Summary = styled.span ``;
|
|
35
|
-
export const ExpandButton = styled(BaseButton) `
|
|
36
|
-
color: #00f;
|
|
37
|
-
font-size: 16px;
|
|
38
|
-
margin-left: 6px;
|
|
39
|
-
margin-top: -2px;
|
|
40
|
-
`;
|
|
41
|
-
export const Fare = styled.span ``;
|
|
42
|
-
export const HideButton = styled(BaseButton) `
|
|
43
|
-
float: right;
|
|
44
|
-
`;
|
|
45
|
-
export const TNCFare = styled.span ``;
|
|
46
|
-
export const TNCFareCompanies = styled.span `
|
|
47
|
-
text-transform: capitalize;
|
|
48
|
-
`;
|
|
49
|
-
export const Timing = styled.span ``;
|
|
50
|
-
export const TransitFare = styled.details `
|
|
51
|
-
display: inline-block;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TripDetailsHeader = exports.TripDetailsBody = exports.TripDetails = exports.TripDetailSummary = exports.TripDetailIcon = exports.TripDetailDescription = exports.TripDetail = exports.TransitFareSingle = exports.TransitFare = exports.Timing = exports.TNCFareCompanies = exports.TNCFare = exports.InvisibleA11yLabel = exports.InvisibleA11yCaption = exports.HideButton = exports.FlexSummary = exports.Fare = exports.ExpandButton = exports.CO2Summary = exports.CO2Description = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
9
|
+
const InvisibleA11yStyles = (0, _styledComponents.css)(["display:inline-block;clip:rect(0,0,0,0);height:0;overflow:hidden;position:absolute;width:0;"]);
|
|
10
|
+
const InvisibleA11yLabel = exports.InvisibleA11yLabel = _styledComponents.default.span.withConfig({
|
|
11
|
+
displayName: "styled__InvisibleA11yLabel",
|
|
12
|
+
componentId: "sc-6q2ok2-0"
|
|
13
|
+
})(["", ""], InvisibleA11yStyles);
|
|
52
14
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
15
|
+
// Warning: https://github.com/opentripplanner/otp-ui/pull/855#discussion_r2248534209
|
|
16
|
+
const InvisibleA11yCaption = exports.InvisibleA11yCaption = _styledComponents.default.caption.withConfig({
|
|
17
|
+
displayName: "styled__InvisibleA11yCaption",
|
|
18
|
+
componentId: "sc-6q2ok2-1"
|
|
19
|
+
})(["", ""], InvisibleA11yStyles);
|
|
20
|
+
const BaseButton = _styledComponents.default.button.withConfig({
|
|
21
|
+
displayName: "styled__BaseButton",
|
|
22
|
+
componentId: "sc-6q2ok2-2"
|
|
23
|
+
})(["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;"]);
|
|
24
|
+
const CO2Description = exports.CO2Description = _styledComponents.default.span.withConfig({
|
|
25
|
+
displayName: "styled__CO2Description",
|
|
26
|
+
componentId: "sc-6q2ok2-3"
|
|
27
|
+
})([""]);
|
|
28
|
+
const CO2Summary = exports.CO2Summary = _styledComponents.default.span.withConfig({
|
|
29
|
+
displayName: "styled__CO2Summary",
|
|
30
|
+
componentId: "sc-6q2ok2-4"
|
|
31
|
+
})([""]);
|
|
32
|
+
const ExpandButton = exports.ExpandButton = (0, _styledComponents.default)(BaseButton).withConfig({
|
|
33
|
+
displayName: "styled__ExpandButton",
|
|
34
|
+
componentId: "sc-6q2ok2-5"
|
|
35
|
+
})(["color:#00f;font-size:16px;margin-left:6px;margin-top:-2px;"]);
|
|
36
|
+
const Fare = exports.Fare = _styledComponents.default.span.withConfig({
|
|
37
|
+
displayName: "styled__Fare",
|
|
38
|
+
componentId: "sc-6q2ok2-6"
|
|
39
|
+
})([""]);
|
|
40
|
+
const HideButton = exports.HideButton = (0, _styledComponents.default)(BaseButton).withConfig({
|
|
41
|
+
displayName: "styled__HideButton",
|
|
42
|
+
componentId: "sc-6q2ok2-7"
|
|
43
|
+
})(["float:right;"]);
|
|
44
|
+
const TNCFare = exports.TNCFare = _styledComponents.default.span.withConfig({
|
|
45
|
+
displayName: "styled__TNCFare",
|
|
46
|
+
componentId: "sc-6q2ok2-8"
|
|
47
|
+
})([""]);
|
|
48
|
+
const TNCFareCompanies = exports.TNCFareCompanies = _styledComponents.default.span.withConfig({
|
|
49
|
+
displayName: "styled__TNCFareCompanies",
|
|
50
|
+
componentId: "sc-6q2ok2-9"
|
|
51
|
+
})(["text-transform:capitalize;"]);
|
|
52
|
+
const Timing = exports.Timing = _styledComponents.default.span.withConfig({
|
|
53
|
+
displayName: "styled__Timing",
|
|
54
|
+
componentId: "sc-6q2ok2-10"
|
|
55
|
+
})([""]);
|
|
56
|
+
const TransitFare = exports.TransitFare = _styledComponents.default.details.withConfig({
|
|
57
|
+
displayName: "styled__TransitFare",
|
|
58
|
+
componentId: "sc-6q2ok2-11"
|
|
59
|
+
})(["display:inline-block;> span{display:block;padding-left:1.75ch;}"]);
|
|
60
|
+
const TransitFareSingle = exports.TransitFareSingle = _styledComponents.default.span.withConfig({
|
|
61
|
+
displayName: "styled__TransitFareSingle",
|
|
62
|
+
componentId: "sc-6q2ok2-12"
|
|
63
|
+
})([""]);
|
|
64
|
+
const FlexSummary = exports.FlexSummary = _styledComponents.default.span.withConfig({
|
|
65
|
+
displayName: "styled__FlexSummary",
|
|
66
|
+
componentId: "sc-6q2ok2-13"
|
|
67
|
+
})([""]);
|
|
68
|
+
const TripDetail = exports.TripDetail = _styledComponents.default.div.withConfig({
|
|
69
|
+
displayName: "styled__TripDetail",
|
|
70
|
+
componentId: "sc-6q2ok2-14"
|
|
71
|
+
})(["margin-top:6px;"]);
|
|
72
|
+
const TripDetailDescription = exports.TripDetailDescription = _styledComponents.default.div.withConfig({
|
|
73
|
+
displayName: "styled__TripDetailDescription",
|
|
74
|
+
componentId: "sc-6q2ok2-15"
|
|
75
|
+
})(["background-color:#fff;border:1px solid #888;font-size:12px;margin-top:2px;padding:8px;"]);
|
|
76
|
+
const TripDetailIcon = exports.TripDetailIcon = _styledComponents.default.div.withConfig({
|
|
77
|
+
displayName: "styled__TripDetailIcon",
|
|
78
|
+
componentId: "sc-6q2ok2-16"
|
|
79
|
+
})(["float:left;font-size:17px;"]);
|
|
80
|
+
const TripDetails = exports.TripDetails = _styledComponents.default.div.withConfig({
|
|
81
|
+
displayName: "styled__TripDetails",
|
|
82
|
+
componentId: "sc-6q2ok2-17"
|
|
83
|
+
})(["background-color:#eee;border-radius:6px;margin-bottom:15px;margin-top:16px;padding:10px 16px;overflow-x:scroll;"]);
|
|
84
|
+
const TripDetailsBody = exports.TripDetailsBody = _styledComponents.default.div.withConfig({
|
|
85
|
+
displayName: "styled__TripDetailsBody",
|
|
86
|
+
componentId: "sc-6q2ok2-18"
|
|
87
|
+
})([""]);
|
|
88
|
+
const TripDetailsHeader = exports.TripDetailsHeader = _styledComponents.default.h2.withConfig({
|
|
89
|
+
displayName: "styled__TripDetailsHeader",
|
|
90
|
+
componentId: "sc-6q2ok2-19"
|
|
91
|
+
})(["font-size:18px;font-weight:600;margin:0;"]);
|
|
92
|
+
const TripDetailSummary = exports.TripDetailSummary = _styledComponents.default.div.withConfig({
|
|
93
|
+
displayName: "styled__TripDetailSummary",
|
|
94
|
+
componentId: "sc-6q2ok2-20"
|
|
95
|
+
})(["margin-left:28px;padding-top:2px;display:flex;align-items:baseline;white-space:pre-wrap;"]);
|
|
97
96
|
//# sourceMappingURL=styled.js.map
|
package/lib/styled.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","
|
|
1
|
+
{"version":3,"file":"styled.js","names":["_styledComponents","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","InvisibleA11yStyles","css","InvisibleA11yLabel","exports","styled","span","withConfig","displayName","componentId","InvisibleA11yCaption","caption","BaseButton","button","CO2Description","CO2Summary","ExpandButton","Fare","HideButton","TNCFare","TNCFareCompanies","Timing","TransitFare","details","TransitFareSingle","FlexSummary","TripDetail","div","TripDetailDescription","TripDetailIcon","TripDetails","TripDetailsBody","TripDetailsHeader","h2","TripDetailSummary"],"sources":["../src/styled.ts"],"sourcesContent":["import styled, { css } from \"styled-components\";\n\nconst InvisibleA11yStyles = css`\n display: inline-block;\n clip: rect(0, 0, 0, 0);\n height: 0;\n overflow: hidden;\n position: absolute;\n width: 0;\n`;\nexport const InvisibleA11yLabel = styled.span`\n ${InvisibleA11yStyles}\n`;\n\n// Warning: https://github.com/opentripplanner/otp-ui/pull/855#discussion_r2248534209\nexport const InvisibleA11yCaption = styled.caption`\n ${InvisibleA11yStyles}\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 overflow-x: scroll;\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-wrap;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAgD,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAA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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _QuestionCircle = require("@styled-icons/fa-solid/QuestionCircle");
|
|
10
|
+
var _TimesCircle = require("@styled-icons/fa-solid/TimesCircle");
|
|
11
|
+
var _reactAnimateHeight = _interopRequireDefault(require("react-animate-height"));
|
|
12
|
+
var _reactIntl = require("react-intl");
|
|
13
|
+
var S = _interopRequireWildcard(require("./styled"));
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
7
15
|
// TODO: Remove this helper method by moving to semantically correct HTML
|
|
8
16
|
function uuidv4() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
18
|
+
// eslint-disable-next-line no-bitwise
|
|
19
|
+
const r = Math.random() * 16 | 0;
|
|
20
|
+
// eslint-disable-next-line no-bitwise
|
|
21
|
+
const v = c === "x" ? r : r & 0x3 | 0x8;
|
|
22
|
+
return v.toString(16);
|
|
23
|
+
});
|
|
16
24
|
}
|
|
17
|
-
const TripDetail = ({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
25
|
+
const TripDetail = ({
|
|
26
|
+
icon,
|
|
27
|
+
summary,
|
|
28
|
+
description,
|
|
29
|
+
className
|
|
30
|
+
}) => {
|
|
31
|
+
const intl = (0, _reactIntl.useIntl)();
|
|
32
|
+
const [expanded, setExpanded] = (0, _react.useState)(false);
|
|
33
|
+
const id = uuidv4();
|
|
34
|
+
const toggle = () => {
|
|
35
|
+
setExpanded(!expanded);
|
|
36
|
+
};
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement(S.TripDetail, {
|
|
38
|
+
role: "group",
|
|
39
|
+
className: className
|
|
40
|
+
}, /*#__PURE__*/_react.default.createElement(S.TripDetailIcon, {
|
|
41
|
+
role: "presentation"
|
|
42
|
+
}, icon), /*#__PURE__*/_react.default.createElement(S.TripDetailSummary, null, summary, description && /*#__PURE__*/_react.default.createElement(S.ExpandButton, {
|
|
43
|
+
"aria-label": expanded ? intl.formatMessage({
|
|
44
|
+
id: "otpUi.TripDetails.hideDetail"
|
|
45
|
+
}) : intl.formatMessage({
|
|
46
|
+
id: "otpUi.TripDetails.showDetail"
|
|
47
|
+
}),
|
|
48
|
+
"aria-controls": id,
|
|
49
|
+
"aria-expanded": expanded,
|
|
50
|
+
id: "expand-button",
|
|
51
|
+
onClick: toggle,
|
|
52
|
+
tabIndex: 0
|
|
53
|
+
}, /*#__PURE__*/_react.default.createElement(_QuestionCircle.QuestionCircle, {
|
|
54
|
+
size: "0.92em"
|
|
55
|
+
}))), /*#__PURE__*/_react.default.createElement(_reactAnimateHeight.default, {
|
|
56
|
+
duration: 300,
|
|
57
|
+
height: expanded ? "auto" : 0
|
|
58
|
+
}, /*#__PURE__*/_react.default.createElement(S.TripDetailDescription, {
|
|
59
|
+
"aria-labelledby": "expand-button",
|
|
60
|
+
id: id
|
|
61
|
+
}, /*#__PURE__*/_react.default.createElement(S.HideButton, {
|
|
62
|
+
role: "presentation",
|
|
63
|
+
onClick: () => setExpanded(false)
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement(_TimesCircle.TimesCircle, {
|
|
65
|
+
size: "0.92em"
|
|
66
|
+
})), description)));
|
|
41
67
|
};
|
|
42
|
-
|
|
68
|
+
var _default = exports.default = TripDetail;
|
|
43
69
|
//# sourceMappingURL=trip-detail.js.map
|
package/lib/trip-detail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trip-detail.js","
|
|
1
|
+
{"version":3,"file":"trip-detail.js","names":["_react","_interopRequireWildcard","require","_QuestionCircle","_TimesCircle","_reactAnimateHeight","_interopRequireDefault","_reactIntl","S","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","uuidv4","replace","c","Math","random","v","toString","TripDetail","icon","summary","description","className","intl","useIntl","expanded","setExpanded","useState","id","toggle","createElement","role","TripDetailIcon","TripDetailSummary","ExpandButton","formatMessage","onClick","tabIndex","QuestionCircle","size","duration","height","TripDetailDescription","HideButton","TimesCircle","_default","exports"],"sources":["../src/trip-detail.tsx"],"sourcesContent":["import React, { ReactElement, useState } from \"react\";\nimport { QuestionCircle } from \"@styled-icons/fa-solid/QuestionCircle\";\nimport { TimesCircle } from \"@styled-icons/fa-solid/TimesCircle\";\n\nimport AnimateHeight from \"react-animate-height\";\nimport { useIntl } from \"react-intl\";\nimport * as S from \"./styled\";\n\ntype Props = {\n className?: string;\n description?: ReactElement | string;\n icon: ReactElement;\n summary: ReactElement | string;\n};\n\n// TODO: Remove this helper method by moving to semantically correct HTML\nfunction uuidv4(): string {\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, function(c) {\n // eslint-disable-next-line no-bitwise\n const r = (Math.random() * 16) | 0;\n // eslint-disable-next-line no-bitwise\n const v = c === \"x\" ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\nconst TripDetail = ({\n icon,\n summary,\n description,\n className\n}: Props): JSX.Element => {\n const intl = useIntl();\n const [expanded, setExpanded] = useState(false);\n\n const id = uuidv4();\n\n const toggle = (): void => {\n setExpanded(!expanded);\n };\n\n return (\n <S.TripDetail role=\"group\" className={className}>\n <S.TripDetailIcon role=\"presentation\">{icon}</S.TripDetailIcon>\n {/* TODO: Adjust the summary and description to be a `summary`/`details` pair, therefore semantically correct */}\n {/* https://github.com/opentripplanner/otp-ui/pull/530#discussion_r1074006057 */}\n <S.TripDetailSummary>\n {summary}\n {description && (\n <S.ExpandButton\n aria-label={\n expanded\n ? intl.formatMessage({\n id: \"otpUi.TripDetails.hideDetail\"\n })\n : intl.formatMessage({\n id: \"otpUi.TripDetails.showDetail\"\n })\n }\n aria-controls={id}\n aria-expanded={expanded}\n id=\"expand-button\"\n onClick={toggle}\n tabIndex={0}\n >\n <QuestionCircle size=\"0.92em\" />\n </S.ExpandButton>\n )}\n </S.TripDetailSummary>\n <AnimateHeight duration={300} height={expanded ? \"auto\" : 0}>\n <S.TripDetailDescription aria-labelledby=\"expand-button\" id={id}>\n {/** This button isn't needed for screen readers as the main expand-button is\n * more convenient.\n */}\n <S.HideButton role=\"presentation\" onClick={() => setExpanded(false)}>\n <TimesCircle size=\"0.92em\" />\n </S.HideButton>\n {description}\n </S.TripDetailDescription>\n </AnimateHeight>\n </S.TripDetail>\n );\n};\n\nexport default TripDetail;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,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AAeH,QAAS;IACxBG,EAAE,EAAC,eAAe;IAClBQ,OAAO,EAAEP,MAAO;IAChBQ,QAAQ,EAAE;EAAE,gBAEZtD,MAAA,CAAAmB,OAAA,CAAA4B,aAAA,CAAC5C,eAAA,CAAAoD,cAAc;IAACC,IAAI,EAAC;EAAQ,CAAE,CACjB,CAEC,CAAC,eACtBxD,MAAA,CAAAmB,OAAA,CAAA4B,aAAA,CAAC1C,mBAAA,CAAAc,OAAa;IAACsC,QAAQ,EAAE,GAAI;IAACC,MAAM,EAAEhB,QAAQ,GAAG,MAAM,GAAG;EAAE,gBAC1D1C,MAAA,CAAAmB,OAAA,CAAA4B,aAAA,CAACvC,CAAC,CAACmD,qBAAqB;IAAC,mBAAgB,eAAe;IAACd,EAAE,EAAEA;EAAG,gBAI9D7C,MAAA,CAAAmB,OAAA,CAAA4B,aAAA,CAACvC,CAAC,CAACoD,UAAU;IAACZ,IAAI,EAAC,cAAc;IAACK,OAAO,EAAEA,CAAA,KAAMV,WAAW,CAAC,KAAK;EAAE,gBAClE3C,MAAA,CAAAmB,OAAA,CAAA4B,aAAA,CAAC3C,YAAA,CAAAyD,WAAW;IAACL,IAAI,EAAC;EAAQ,CAAE,CAChB,CAAC,EACdlB,WACsB,CACZ,CACH,CAAC;AAEnB,CAAC;AAAC,IAAAwB,QAAA,GAAAC,OAAA,CAAA5C,OAAA,GAEagB,UAAU","ignoreList":[]}
|
package/lib/types.js
CHANGED
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["// Prettier does not recognize the import type syntax.\n// eslint-disable-next-line prettier/prettier\nimport type { \n FareProductSelector, \n Itinerary, \n Leg, \n MassUnitOption,\n Money\n } from \"@opentripplanner/types\";\n\nexport interface TimeActiveDetailsProps {\n bikeMinutes: number;\n minutesActive?: number;\n walkMinutes: number;\n}\n\nexport interface CO2ConfigType {\n carbonIntensity?: Record<string, number>;\n units?: MassUnitOption;\n enabled?: boolean;\n}\n\nexport interface DepartureDetailsProps {\n departureDate: Date;\n}\n\n\n// Total fare amount corresponding to a fare key\nexport type FareTotals = (FareProductSelector & { price: Money })[]\n\nexport interface FareDetailsProps {\n legs: Leg[];\n maxTNCFare: number;\n minTNCFare: number;\n}\n\nexport interface TripDetailsProps {\n /**\n * Used for additional styling with styled components for example.\n */\n className?: string;\n /**\n * Object containing the CO₂ config.\n */\n co2Config?: CO2ConfigType;\n /**\n * Determines which transit fare should be displayed by default, should there be multiple transit fare types.\n */\n defaultFareType?: FareProductSelector;\n /**\n * Slot for a custom component to render the expandable section for departure.\n */\n DepartureDetails?: React.ElementType<DepartureDetailsProps>;\n /**\n * Slot for a custom component to render the expandable section for fares.\n */\n FareDetails?: React.ElementType<FareDetailsProps>;\n /**\n * Itinerary that the user has selected to view, contains multiple legs.\n */\n itinerary: Itinerary;\n /**\n * show the '~' symbol in the trip details panel\n */\n showApproximateMinutesActive?: boolean;\n /**\n * Slot for a custom component to render the expandable section for time active.\n */\n TimeActiveDetails?: React.ElementType<TimeActiveDetailsProps>;\n}"],"mappings":"","ignoreList":[]}
|
package/lib/utils.js
CHANGED
|
@@ -1,24 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.boldText = boldText;
|
|
8
|
+
exports.renderFare = renderFare;
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _reactIntl = require("react-intl");
|
|
3
11
|
/**
|
|
4
12
|
* Format text bold (used with FormattedMessage).
|
|
5
13
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
14
|
+
function boldText(contents) {
|
|
15
|
+
return /*#__PURE__*/_react.default.createElement("strong", null, contents);
|
|
8
16
|
}
|
|
17
|
+
|
|
9
18
|
/**
|
|
10
19
|
* Render formatted fare.
|
|
11
20
|
* @param currencyCode The ISO currency code to use (USD, GBP, EUR).
|
|
12
21
|
* @param fare The fare value, in currency units, to be shown.
|
|
13
22
|
* @returns The formatted fare value according to the selected locale.
|
|
14
23
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
function renderFare(currencyCode, fare) {
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedNumber, {
|
|
26
|
+
currency: currencyCode
|
|
27
|
+
// For dollars in locales such as 'fr',
|
|
28
|
+
// this will limit the display to just the dollar sign
|
|
29
|
+
// (otherwise it will render e.g. '2,50 $US' instead of '2,50 $').
|
|
30
|
+
,
|
|
31
|
+
currencyDisplay: "narrowSymbol",
|
|
32
|
+
value: fare
|
|
33
|
+
// eslint-disable-next-line react/style-prop-object
|
|
34
|
+
,
|
|
35
|
+
style: "currency"
|
|
36
|
+
});
|
|
23
37
|
}
|
|
24
38
|
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_react","_interopRequireDefault","require","_reactIntl","boldText","contents","default","createElement","renderFare","currencyCode","fare","FormattedNumber","currency","currencyDisplay","value","style"],"sources":["../src/utils.tsx"],"sourcesContent":["import React, { ReactElement, ReactNode } from \"react\";\nimport { FormattedNumber } from \"react-intl\";\n\n/**\n * Format text bold (used with FormattedMessage).\n */\nexport function boldText(contents: ReactNode): ReactElement {\n return <strong>{contents}</strong>;\n}\n\n/**\n * Render formatted fare.\n * @param currencyCode The ISO currency code to use (USD, GBP, EUR).\n * @param fare The fare value, in currency units, to be shown.\n * @returns The formatted fare value according to the selected locale.\n */\nexport function renderFare(currencyCode: string, fare: number): ReactElement {\n return (\n <FormattedNumber\n currency={currencyCode}\n // For dollars in locales such as 'fr',\n // this will limit the display to just the dollar sign\n // (otherwise it will render e.g. '2,50 $US' instead of '2,50 $').\n currencyDisplay=\"narrowSymbol\"\n value={fare}\n // eslint-disable-next-line react/style-prop-object\n style=\"currency\"\n />\n );\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACO,SAASE,QAAQA,CAACC,QAAmB,EAAgB;EAC1D,oBAAOL,MAAA,CAAAM,OAAA,CAAAC,aAAA,iBAASF,QAAiB,CAAC;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,UAAUA,CAACC,YAAoB,EAAEC,IAAY,EAAgB;EAC3E,oBACEV,MAAA,CAAAM,OAAA,CAAAC,aAAA,CAACJ,UAAA,CAAAQ,eAAe;IACdC,QAAQ,EAAEH;IACV;IACA;IACA;IAAA;IACAI,eAAe,EAAC,cAAc;IAC9BC,KAAK,EAAEJ;IACP;IAAA;IACAK,KAAK,EAAC;EAAU,CACjB,CAAC;AAEN","ignoreList":[]}
|