@opentripplanner/trip-details 1.5.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/custom-messages.yml +7 -0
- package/esm/index.js +258 -126
- package/esm/index.js.map +1 -1
- package/esm/styled.js +30 -18
- package/esm/styled.js.map +1 -1
- package/esm/trip-detail.js +0 -9
- package/esm/trip-detail.js.map +1 -1
- package/esm/types.js +2 -0
- package/esm/types.js.map +1 -0
- package/i18n/en-US.yml +44 -0
- package/i18n/fr.yml +32 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +241 -122
- package/lib/index.js.map +1 -1
- package/lib/styled.d.ts +23 -0
- package/lib/styled.d.ts.map +1 -0
- package/lib/styled.js +40 -19
- package/lib/styled.js.map +1 -1
- package/lib/trip-detail.d.ts +18 -0
- package/lib/trip-detail.d.ts.map +1 -0
- package/lib/trip-detail.js +0 -12
- package/lib/trip-detail.js.map +1 -1
- package/lib/types.d.ts +67 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/package.json +11 -8
- package/src/TripDetails.story.tsx +273 -0
- package/src/__unpublished__/external-types.d.ts +22 -0
- package/src/__unpublished__/messages.d.ts +2 -0
- package/src/index.tsx +404 -0
- package/src/{styled.js → styled.ts} +6 -0
- package/src/{trip-detail.js → trip-detail.tsx} +17 -18
- package/src/types.ts +74 -0
- package/tsconfig.json +15 -0
- package/tsconfig.tsbuildinfo +4432 -0
- package/src/TripDetails.story.js +0 -147
- package/src/index.js +0 -262
|
@@ -56,6 +56,12 @@ export const TransitFare = styled.details`
|
|
|
56
56
|
`;
|
|
57
57
|
export const TransitFareSingle = styled.span``;
|
|
58
58
|
|
|
59
|
+
export const FlexSummary = styled.span``;
|
|
60
|
+
|
|
61
|
+
export const FlexPickupSummary = styled.span``;
|
|
62
|
+
|
|
63
|
+
export const FlexDropOffSummary = styled.span``;
|
|
64
|
+
|
|
59
65
|
export const TripDetail = styled.div`
|
|
60
66
|
margin-top: 6px;
|
|
61
67
|
`;
|
|
@@ -1,34 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { Component } from "react";
|
|
1
|
+
import React, { Component, ReactElement } from "react";
|
|
3
2
|
import { QuestionCircle } from "@styled-icons/fa-solid/QuestionCircle";
|
|
4
3
|
import { TimesCircle } from "@styled-icons/fa-solid/TimesCircle";
|
|
5
4
|
import { VelocityTransitionGroup } from "velocity-react";
|
|
6
5
|
|
|
7
6
|
import * as S from "./styled";
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
type Props = {
|
|
9
|
+
description?: ReactElement | string;
|
|
10
|
+
icon: ReactElement;
|
|
11
|
+
summary: ReactElement | string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type State = {
|
|
15
|
+
expanded: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default class TripDetail extends Component<Props, State> {
|
|
19
|
+
constructor(props: Props) {
|
|
11
20
|
super(props);
|
|
12
21
|
this.state = {
|
|
13
22
|
expanded: false
|
|
14
23
|
};
|
|
15
24
|
}
|
|
16
25
|
|
|
17
|
-
toggle = () => {
|
|
26
|
+
toggle = (): void => {
|
|
18
27
|
const { expanded } = this.state;
|
|
19
28
|
if (expanded) this.onHideClick();
|
|
20
29
|
else this.onExpandClick();
|
|
21
30
|
};
|
|
22
31
|
|
|
23
|
-
onExpandClick = () => {
|
|
32
|
+
onExpandClick = (): void => {
|
|
24
33
|
this.setState({ expanded: true });
|
|
25
34
|
};
|
|
26
35
|
|
|
27
|
-
onHideClick = () => {
|
|
36
|
+
onHideClick = (): void => {
|
|
28
37
|
this.setState({ expanded: false });
|
|
29
38
|
};
|
|
30
39
|
|
|
31
|
-
render() {
|
|
40
|
+
render(): ReactElement {
|
|
32
41
|
const { icon, summary, description } = this.props;
|
|
33
42
|
const { expanded } = this.state;
|
|
34
43
|
return (
|
|
@@ -59,13 +68,3 @@ export default class TripDetail extends Component {
|
|
|
59
68
|
);
|
|
60
69
|
}
|
|
61
70
|
}
|
|
62
|
-
|
|
63
|
-
TripDetail.propTypes = {
|
|
64
|
-
icon: PropTypes.node.isRequired,
|
|
65
|
-
summary: PropTypes.node.isRequired,
|
|
66
|
-
description: PropTypes.node
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
TripDetail.defaultProps = {
|
|
70
|
-
description: undefined
|
|
71
|
-
};
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Prettier does not recognize the import type syntax.
|
|
2
|
+
// eslint-disable-next-line prettier/prettier
|
|
3
|
+
import type { Itinerary } from "@opentripplanner/types";
|
|
4
|
+
import type { ReactElement } from "react";
|
|
5
|
+
|
|
6
|
+
export interface CaloriesDetailsProps {
|
|
7
|
+
bikeSeconds: number;
|
|
8
|
+
calories: number;
|
|
9
|
+
walkSeconds: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DepartureDetailsProps {
|
|
13
|
+
departureDate: Date;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TransitFareData {
|
|
17
|
+
[key: string]: {
|
|
18
|
+
currency: {
|
|
19
|
+
currencyCode: string
|
|
20
|
+
defaultFractionDigits: number
|
|
21
|
+
currency: string
|
|
22
|
+
symbol: string
|
|
23
|
+
};
|
|
24
|
+
cents: number;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FareDetailsProps {
|
|
29
|
+
maxTNCFare: number;
|
|
30
|
+
minTNCFare: number;
|
|
31
|
+
transitFares: TransitFareData;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface TransitFareProps {
|
|
35
|
+
fareKey: string;
|
|
36
|
+
fareNameFallback?: ReactElement;
|
|
37
|
+
fareKeyNameMap: {
|
|
38
|
+
[key: string]: string;
|
|
39
|
+
};
|
|
40
|
+
transitFares: TransitFareData;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface TripDetailsProps {
|
|
44
|
+
/**
|
|
45
|
+
* Slot for a custom component to render the expandable section for calories.
|
|
46
|
+
*/
|
|
47
|
+
CaloriesDetails?: React.ElementType<CaloriesDetailsProps>;
|
|
48
|
+
/**
|
|
49
|
+
* Used for additional styling with styled components for example.
|
|
50
|
+
*/
|
|
51
|
+
className?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Determines which transit fare should be displayed by default, should there be multiple transit fare types.
|
|
54
|
+
*/
|
|
55
|
+
defaultFareKey?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Slot for a custom component to render the expandable section for departure.
|
|
58
|
+
*/
|
|
59
|
+
DepartureDetails?: React.ElementType<DepartureDetailsProps>;
|
|
60
|
+
/**
|
|
61
|
+
* Slot for a custom component to render the expandable section for fares.
|
|
62
|
+
*/
|
|
63
|
+
FareDetails?: React.ElementType<FareDetailsProps>;
|
|
64
|
+
/**
|
|
65
|
+
* Mapping between fare keys and human-readable names for them.
|
|
66
|
+
*/
|
|
67
|
+
fareKeyNameMap?: {
|
|
68
|
+
[name: string]: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Itinerary that the user has selected to view, contains multiple legs.
|
|
72
|
+
*/
|
|
73
|
+
itinerary: Itinerary;
|
|
74
|
+
}
|
package/tsconfig.json
ADDED