@opentripplanner/core-utils 4.11.6-alpha.1 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/deprecated-with-types.js +47 -0
- package/esm/deprecated-with-types.js.map +1 -0
- package/esm/index.js +0 -4
- package/esm/index.js.map +1 -1
- package/esm/itinerary.js +1 -1
- package/esm/itinerary.js.map +1 -1
- package/esm/map.js +16 -8
- package/esm/map.js.map +1 -1
- package/esm/route.js +5 -3
- package/esm/route.js.map +1 -1
- package/esm/storage.js +1 -0
- package/esm/storage.js.map +1 -1
- package/esm/time.js +6 -36
- package/esm/time.js.map +1 -1
- package/esm/ui.js +1 -1
- package/esm/ui.js.map +1 -1
- package/lib/deprecated-with-types.d.ts +23 -0
- package/lib/deprecated-with-types.d.ts.map +1 -0
- package/lib/deprecated-with-types.js +61 -0
- package/lib/deprecated-with-types.js.map +1 -0
- package/lib/index.d.ts +19 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +0 -6
- package/lib/index.js.map +1 -1
- package/lib/itinerary.d.ts +113 -0
- package/lib/itinerary.d.ts.map +1 -0
- package/lib/itinerary.js +2 -1
- package/lib/itinerary.js.map +1 -1
- package/lib/map.d.ts +30 -0
- package/lib/map.d.ts.map +1 -0
- package/lib/map.js +15 -7
- package/lib/map.js.map +1 -1
- package/lib/route.d.ts +98 -0
- package/lib/route.d.ts.map +1 -0
- package/lib/route.js +5 -3
- package/lib/route.js.map +1 -1
- package/lib/storage.d.ts +19 -0
- package/lib/storage.d.ts.map +1 -0
- package/lib/storage.js +2 -0
- package/lib/storage.js.map +1 -1
- package/lib/time.d.ts +65 -0
- package/lib/time.d.ts.map +1 -0
- package/lib/time.js +22 -39
- package/lib/time.js.map +1 -1
- package/lib/ui.d.ts +13 -0
- package/lib/ui.d.ts.map +1 -0
- package/lib/ui.js +1 -1
- package/lib/ui.js.map +1 -1
- package/package.json +4 -1
- package/src/__tests__/__snapshots__/route.js.snap +30 -30
- package/src/deprecated-with-types.ts +62 -0
- package/src/{index.js → index.ts} +0 -4
- package/src/{itinerary.js → itinerary.ts} +70 -36
- package/src/{map.js → map.ts} +51 -28
- package/src/{route.js → route.ts} +52 -28
- package/src/{storage.js → storage.ts} +6 -5
- package/src/{time.js → time.ts} +28 -46
- package/src/{ui.js → ui.ts} +8 -8
- package/tsconfig.json +15 -0
- package/tsconfig.tsbuildinfo +4921 -0
- package/esm/messages.js +0 -25
- package/esm/messages.js.map +0 -1
- package/esm/types.js +0 -560
- package/esm/types.js.map +0 -1
- package/lib/messages.js +0 -29
- package/lib/messages.js.map +0 -1
- package/lib/types.js +0 -661
- package/lib/types.js.map +0 -1
- package/src/messages.js +0 -20
- package/src/types.js +0 -605
package/src/types.js
DELETED
|
@@ -1,605 +0,0 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
|
-
import { ReactPropTypeLocationNames } from "react";
|
|
3
|
-
import { isValidLatLng } from "./map";
|
|
4
|
-
|
|
5
|
-
export const companyType = PropTypes.shape({
|
|
6
|
-
id: PropTypes.string.isRequired,
|
|
7
|
-
label: PropTypes.string.isRequired,
|
|
8
|
-
/* a comma-separated string listing the modes that this company has */
|
|
9
|
-
modes: PropTypes.string.isRequired
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Leaflet path properties to use to style a CircleMarker, Marker or Polyline.
|
|
14
|
-
*
|
|
15
|
-
* See https://leafletjs.com/reference-1.6.0.html#path
|
|
16
|
-
*/
|
|
17
|
-
export const leafletPathType = PropTypes.shape({
|
|
18
|
-
bubblingMouseEvents: PropTypes.bool,
|
|
19
|
-
color: PropTypes.string,
|
|
20
|
-
className: PropTypes.string,
|
|
21
|
-
dashArray: PropTypes.string,
|
|
22
|
-
dashOffset: PropTypes.string,
|
|
23
|
-
fill: PropTypes.bool,
|
|
24
|
-
fillColor: PropTypes.string,
|
|
25
|
-
fillOpacity: PropTypes.number,
|
|
26
|
-
fillRule: PropTypes.string,
|
|
27
|
-
lineCap: PropTypes.string,
|
|
28
|
-
lineJoin: PropTypes.string,
|
|
29
|
-
opacity: PropTypes.number,
|
|
30
|
-
renderer: PropTypes.func,
|
|
31
|
-
stroke: PropTypes.bool,
|
|
32
|
-
weight: PropTypes.number
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Describes some options to help display data about a transit agency that is
|
|
37
|
-
* configured in an opentripplanner instance.
|
|
38
|
-
*/
|
|
39
|
-
export const transitOperatorType = PropTypes.shape({
|
|
40
|
-
agencyId: PropTypes.string.isRequired,
|
|
41
|
-
defaultRouteColor: PropTypes.string,
|
|
42
|
-
defaultRouteTextColor: PropTypes.string,
|
|
43
|
-
feedId: PropTypes.string.isRequired,
|
|
44
|
-
logo: PropTypes.string,
|
|
45
|
-
longNameSplitter: PropTypes.string,
|
|
46
|
-
name: PropTypes.string,
|
|
47
|
-
order: PropTypes.number
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export const languageConfigType = PropTypes.shape({
|
|
51
|
-
stopViewer: PropTypes.string
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Defines which symbol to render based on a zoom level, and optionally by entity type.
|
|
56
|
-
* (Only one symbol is rendered for any zoom level.)
|
|
57
|
-
*/
|
|
58
|
-
export const zoomBasedSymbolType = PropTypes.shape({
|
|
59
|
-
/**
|
|
60
|
-
* A function with the signature (entity: object) => string
|
|
61
|
-
* that determines the type of an entity.
|
|
62
|
-
* symbolByType and getType must be either be both specified or both omitted.
|
|
63
|
-
*/
|
|
64
|
-
getType: PropTypes.func,
|
|
65
|
-
/**
|
|
66
|
-
* The zoom level beginning at which the marker is drawn,
|
|
67
|
-
* unless another marker with a higher minZoom is met.
|
|
68
|
-
*/
|
|
69
|
-
minZoom: PropTypes.number.isRequired,
|
|
70
|
-
/**
|
|
71
|
-
* The symbol-representing component to draw, with the signature
|
|
72
|
-
* ({ entity: object, zoom: number }) => Element
|
|
73
|
-
* where entity must have an id attribute and contain coordinates information for placement on the map.
|
|
74
|
-
*/
|
|
75
|
-
symbol: PropTypes.elementType.isRequired,
|
|
76
|
-
/**
|
|
77
|
-
* The symbol-representing component to draw for each entity type,
|
|
78
|
-
* with the same signature as symbol. If a type returned by getType() is not listed,
|
|
79
|
-
* then the component defined in the 'symbol' attribute will be rendered by default.
|
|
80
|
-
* symbolByType and getType must be either be both specified or both omitted.
|
|
81
|
-
*/
|
|
82
|
-
symbolByType: PropTypes.objectOf(PropTypes.elementType)
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
/** describes the objects from the real-time vehicle service */
|
|
86
|
-
export const transitVehicleType = PropTypes.shape({
|
|
87
|
-
routeShortName: PropTypes.string,
|
|
88
|
-
routeLongName: PropTypes.string,
|
|
89
|
-
routeType: PropTypes.string,
|
|
90
|
-
|
|
91
|
-
status: PropTypes.string,
|
|
92
|
-
reportDate: PropTypes.string,
|
|
93
|
-
seconds: PropTypes.number,
|
|
94
|
-
|
|
95
|
-
stopSequence: PropTypes.number,
|
|
96
|
-
stopId: PropTypes.string,
|
|
97
|
-
vehicleId: PropTypes.string,
|
|
98
|
-
tripId: PropTypes.string,
|
|
99
|
-
blockId: PropTypes.string,
|
|
100
|
-
|
|
101
|
-
lat: PropTypes.number,
|
|
102
|
-
lon: PropTypes.number,
|
|
103
|
-
heading: PropTypes.number
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
export const vehicleRentalMapOverlaySymbolsType = PropTypes.arrayOf(
|
|
107
|
-
PropTypes.oneOfType([
|
|
108
|
-
PropTypes.shape({
|
|
109
|
-
dockStrokeColor: PropTypes.string,
|
|
110
|
-
fillColor: PropTypes.string,
|
|
111
|
-
minZoom: PropTypes.number.isRequired,
|
|
112
|
-
pixels: PropTypes.number,
|
|
113
|
-
type: PropTypes.string.isRequired
|
|
114
|
-
}),
|
|
115
|
-
zoomBasedSymbolType
|
|
116
|
-
]).isRequired
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Represents the expected configuration of the webapp.
|
|
121
|
-
*
|
|
122
|
-
* Note: this is an incomplete type mapping.
|
|
123
|
-
*/
|
|
124
|
-
export const configType = PropTypes.shape({
|
|
125
|
-
companies: PropTypes.arrayOf(companyType.isRequired),
|
|
126
|
-
dateTime: PropTypes.shape({
|
|
127
|
-
timeFormat: PropTypes.string,
|
|
128
|
-
dateFormat: PropTypes.string,
|
|
129
|
-
longDateFormat: PropTypes.string
|
|
130
|
-
}),
|
|
131
|
-
// TODO: add full typing
|
|
132
|
-
map: PropTypes.shape({
|
|
133
|
-
overlays: PropTypes.arrayOf(
|
|
134
|
-
PropTypes.shape({
|
|
135
|
-
/**
|
|
136
|
-
* The applicable companies this overlay covers. Only applicable in
|
|
137
|
-
* certain vehicle rental overlays.
|
|
138
|
-
*/
|
|
139
|
-
companies: PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
140
|
-
name: PropTypes.string.isRequired,
|
|
141
|
-
/**
|
|
142
|
-
* The applicable map symbols. Only applicable in vehicle rental
|
|
143
|
-
* overlays.
|
|
144
|
-
*/
|
|
145
|
-
mapSymbols: vehicleRentalMapOverlaySymbolsType,
|
|
146
|
-
/**
|
|
147
|
-
* Only used during park and ride queries. This will filter out P&Rs
|
|
148
|
-
* that are further than the specified number of meters from a transit
|
|
149
|
-
* stop.
|
|
150
|
-
*/
|
|
151
|
-
maxTransitDistance: PropTypes.number,
|
|
152
|
-
/**
|
|
153
|
-
* The applicable modes this overlay covers. Only applicable in certain
|
|
154
|
-
* vehicle rental overlays.
|
|
155
|
-
*/
|
|
156
|
-
modes: PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
157
|
-
/**
|
|
158
|
-
* The type of overlay. Currently valid values include:
|
|
159
|
-
*
|
|
160
|
-
* "bike-rental", "car-rental", "micromobility-rental", "park-and-ride",
|
|
161
|
-
* "stops", "tile"
|
|
162
|
-
*/
|
|
163
|
-
type: PropTypes.string.isRequired
|
|
164
|
-
})
|
|
165
|
-
)
|
|
166
|
-
}),
|
|
167
|
-
transitOperators: PropTypes.arrayOf(transitOperatorType)
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const feedScopedIdType = PropTypes.shape({
|
|
171
|
-
agencyId: PropTypes.string,
|
|
172
|
-
id: PropTypes.string
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
export const encodedPolylineType = PropTypes.shape({
|
|
176
|
-
length: PropTypes.number.isRequired,
|
|
177
|
-
points: PropTypes.string.isRequired
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const elevationData = PropTypes.arrayOf(
|
|
181
|
-
PropTypes.shape({
|
|
182
|
-
first: PropTypes.number.isRequired,
|
|
183
|
-
second: PropTypes.number.isRequired
|
|
184
|
-
}).isRequired
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
const alertType = PropTypes.shape({
|
|
188
|
-
alertHeaderText: PropTypes.string,
|
|
189
|
-
alertDescriptionText: PropTypes.string,
|
|
190
|
-
alertUrl: PropTypes.string,
|
|
191
|
-
effectiveStartDate: PropTypes.number
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Represents steps in a leg in an itinerary of an OTP plan response. These are
|
|
196
|
-
* only for non-transit modes.
|
|
197
|
-
* See documentation here: http://otp-docs.ibi-transit.com/api/json_WalkStep.html
|
|
198
|
-
*/
|
|
199
|
-
export const stepsType = PropTypes.arrayOf(
|
|
200
|
-
PropTypes.shape({
|
|
201
|
-
absoluteDirection: PropTypes.string,
|
|
202
|
-
alerts: PropTypes.arrayOf(alertType),
|
|
203
|
-
area: PropTypes.bool.isRequired,
|
|
204
|
-
bogusName: PropTypes.bool.isRequired,
|
|
205
|
-
distance: PropTypes.number.isRequired,
|
|
206
|
-
elevation: elevationData.isRequired,
|
|
207
|
-
lat: PropTypes.number.isRequired,
|
|
208
|
-
lon: PropTypes.number.isRequired,
|
|
209
|
-
relativeDirection: PropTypes.string.isRequired,
|
|
210
|
-
stayOn: PropTypes.bool.isRequired,
|
|
211
|
-
streetName: PropTypes.string.isRequired
|
|
212
|
-
})
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
export const placeType = PropTypes.shape({
|
|
216
|
-
arrival: PropTypes.number,
|
|
217
|
-
departure: PropTypes.number,
|
|
218
|
-
lat: PropTypes.number.isRequired,
|
|
219
|
-
lon: PropTypes.number.isRequired,
|
|
220
|
-
name: PropTypes.string.isRequired,
|
|
221
|
-
networks: PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
222
|
-
stopCode: PropTypes.string,
|
|
223
|
-
stopId: PropTypes.string,
|
|
224
|
-
stopIndex: PropTypes.number,
|
|
225
|
-
stopSequence: PropTypes.number,
|
|
226
|
-
vertexType: PropTypes.string.isRequired,
|
|
227
|
-
zoneId: PropTypes.string
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Represents a leg in an itinerary of an OTP plan response. Each leg represents
|
|
232
|
-
* a portion of the overall itinerary that is done until either reaching the
|
|
233
|
-
* destination or transitioning to another mode of travel. See OTP webservice
|
|
234
|
-
* documentation here:
|
|
235
|
-
* http://otp-docs.ibi-transit.com/api/json_Leg.html
|
|
236
|
-
*/
|
|
237
|
-
export const legType = PropTypes.shape({
|
|
238
|
-
agencyId: PropTypes.string,
|
|
239
|
-
agencyName: PropTypes.string,
|
|
240
|
-
agencyTimeZoneOffset: PropTypes.number.isRequired,
|
|
241
|
-
agencyUrl: PropTypes.string,
|
|
242
|
-
alerts: PropTypes.arrayOf(alertType),
|
|
243
|
-
arrivalDelay: PropTypes.number.isRequired,
|
|
244
|
-
departureDelay: PropTypes.number.isRequired,
|
|
245
|
-
distance: PropTypes.number.isRequired,
|
|
246
|
-
duration: PropTypes.number.isRequired,
|
|
247
|
-
endTime: PropTypes.number.isRequired,
|
|
248
|
-
from: placeType.isRequired,
|
|
249
|
-
hailedCar: PropTypes.bool,
|
|
250
|
-
headsign: PropTypes.string,
|
|
251
|
-
interlineWithPreviousLeg: PropTypes.bool.isRequired,
|
|
252
|
-
intermediateStops: PropTypes.arrayOf(placeType).isRequired,
|
|
253
|
-
interStopGeometry: PropTypes.arrayOf(encodedPolylineType),
|
|
254
|
-
legGeometry: encodedPolylineType.isRequired,
|
|
255
|
-
mode: PropTypes.string.isRequired,
|
|
256
|
-
pathway: PropTypes.bool.isRequired,
|
|
257
|
-
realTime: PropTypes.bool.isRequired,
|
|
258
|
-
rentedBike: PropTypes.bool.isRequired,
|
|
259
|
-
rentedCar: PropTypes.bool.isRequired,
|
|
260
|
-
rentedVehicle: PropTypes.bool.isRequired,
|
|
261
|
-
route: PropTypes.string,
|
|
262
|
-
routeId: PropTypes.string,
|
|
263
|
-
routeType: PropTypes.number,
|
|
264
|
-
serviceDate: PropTypes.string,
|
|
265
|
-
startTime: PropTypes.number.isRequired,
|
|
266
|
-
steps: stepsType.isRequired,
|
|
267
|
-
tncData: PropTypes.shape({
|
|
268
|
-
company: PropTypes.string.isRequired,
|
|
269
|
-
currency: PropTypes.string.isRequired,
|
|
270
|
-
displayName: PropTypes.string.isRequired,
|
|
271
|
-
estimatedArrival: PropTypes.number.isRequired,
|
|
272
|
-
maxCost: PropTypes.number.isRequired,
|
|
273
|
-
minCost: PropTypes.number.isRequired,
|
|
274
|
-
productId: PropTypes.string.isRequired,
|
|
275
|
-
travelDuration: PropTypes.number.isRequired
|
|
276
|
-
}),
|
|
277
|
-
to: placeType.isRequired,
|
|
278
|
-
transitLeg: PropTypes.bool.isRequired,
|
|
279
|
-
tripBlockId: PropTypes.string,
|
|
280
|
-
tripId: PropTypes.string
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
const moneyType = PropTypes.shape({
|
|
284
|
-
cents: PropTypes.number.isRequired,
|
|
285
|
-
currency: PropTypes.shape({
|
|
286
|
-
defaultFractionDigits: PropTypes.number.isRequired,
|
|
287
|
-
currencyCode: PropTypes.string.isRequired,
|
|
288
|
-
symbol: PropTypes.string.isRequired,
|
|
289
|
-
currency: PropTypes.string.isRequired
|
|
290
|
-
}).isRequired
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Represents the fare component of an itinerary of an OTP plan response. See
|
|
295
|
-
* detailed documentation in OTP webservice documentation here:
|
|
296
|
-
* http://otp-docs.ibi-transit.com/api/json_Fare.html
|
|
297
|
-
*
|
|
298
|
-
* NOTE: so far the fare includes ONLY a fare encountered on public transit and
|
|
299
|
-
* not any bike rental or TNC rental fees.
|
|
300
|
-
*/
|
|
301
|
-
export const fareType = PropTypes.shape({
|
|
302
|
-
details: PropTypes.objectOf(
|
|
303
|
-
PropTypes.arrayOf(
|
|
304
|
-
PropTypes.shape({
|
|
305
|
-
fareId: PropTypes.oneOfType([PropTypes.string, feedScopedIdType])
|
|
306
|
-
.isRequired,
|
|
307
|
-
price: moneyType.isRequired,
|
|
308
|
-
routes: PropTypes.arrayOf(
|
|
309
|
-
PropTypes.oneOfType([PropTypes.string, feedScopedIdType])
|
|
310
|
-
).isRequired
|
|
311
|
-
})
|
|
312
|
-
).isRequired
|
|
313
|
-
),
|
|
314
|
-
fare: PropTypes.objectOf(moneyType)
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Represents an itinerary of an OTP plan response. See detailed documentation
|
|
319
|
-
* in OTP webservice documentation here:
|
|
320
|
-
* http://otp-docs.ibi-transit.com/api/json_Itinerary.html
|
|
321
|
-
*/
|
|
322
|
-
export const itineraryType = PropTypes.shape({
|
|
323
|
-
duration: PropTypes.number.isRequired,
|
|
324
|
-
elevationGained: PropTypes.number.isRequired,
|
|
325
|
-
elevationLost: PropTypes.number.isRequired,
|
|
326
|
-
endTime: PropTypes.number.isRequired,
|
|
327
|
-
fare: fareType,
|
|
328
|
-
legs: PropTypes.arrayOf(legType).isRequired,
|
|
329
|
-
startTime: PropTypes.number.isRequired,
|
|
330
|
-
tooSloped: PropTypes.bool,
|
|
331
|
-
transfers: PropTypes.number.isRequired,
|
|
332
|
-
transitTime: PropTypes.number.isRequired,
|
|
333
|
-
waitingTime: PropTypes.number.isRequired,
|
|
334
|
-
walkDistance: PropTypes.number.isRequired,
|
|
335
|
-
walkLimitExceeded: PropTypes.bool.isRequired,
|
|
336
|
-
walkTime: PropTypes.number.isRequired
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Used to model a location that is used in planning a trip.
|
|
341
|
-
*/
|
|
342
|
-
export const locationType = PropTypes.shape({
|
|
343
|
-
lat: PropTypes.number.isRequired,
|
|
344
|
-
lon: PropTypes.number.isRequired,
|
|
345
|
-
name: PropTypes.string.isRequired,
|
|
346
|
-
/**
|
|
347
|
-
* This is only used location that a user has saved. Can be either:
|
|
348
|
-
* "home" or "work"
|
|
349
|
-
*/
|
|
350
|
-
type: PropTypes.string
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Used to help display the time of day within the context of a particular itinerary.
|
|
355
|
-
*/
|
|
356
|
-
export const timeOptionsType = PropTypes.shape({
|
|
357
|
-
/**
|
|
358
|
-
* A format string template to be used to display a date using moment.js
|
|
359
|
-
*/
|
|
360
|
-
format: PropTypes.string,
|
|
361
|
-
/*
|
|
362
|
-
* The timezone offset in milliseconds if any should be added. This is
|
|
363
|
-
* typically calculated using the itinerary.js#getTimeZoneOffset function.
|
|
364
|
-
*/
|
|
365
|
-
offset: PropTypes.number
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* This models data about a stop and it's associated routes that is obtained
|
|
370
|
-
* from a transit index API.
|
|
371
|
-
*/
|
|
372
|
-
export const transitIndexStopWithRoutes = PropTypes.shape({
|
|
373
|
-
/**
|
|
374
|
-
* The stop code if the stop has one
|
|
375
|
-
*/
|
|
376
|
-
code: PropTypes.string,
|
|
377
|
-
/**
|
|
378
|
-
* The distance from the user to the stop in meters
|
|
379
|
-
*/
|
|
380
|
-
dist: PropTypes.number,
|
|
381
|
-
lat: PropTypes.number,
|
|
382
|
-
lon: PropTypes.number,
|
|
383
|
-
name: PropTypes.string,
|
|
384
|
-
routes: PropTypes.arrayOf(
|
|
385
|
-
PropTypes.shape({
|
|
386
|
-
longName: PropTypes.string,
|
|
387
|
-
shortName: PropTypes.string
|
|
388
|
-
})
|
|
389
|
-
)
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
export const stopLayerStopType = PropTypes.shape({
|
|
393
|
-
id: PropTypes.string.isRequired,
|
|
394
|
-
name: PropTypes.string.isRequired,
|
|
395
|
-
lat: PropTypes.number.isRequired,
|
|
396
|
-
lon: PropTypes.number.isRequired
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
const transitivePlaceType = PropTypes.shape({
|
|
400
|
-
place_id: PropTypes.string.isRequired,
|
|
401
|
-
type: PropTypes.string.isRequired
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
export const transitiveDataType = PropTypes.shape({
|
|
405
|
-
journeys: PropTypes.arrayOf(
|
|
406
|
-
PropTypes.shape({
|
|
407
|
-
journey_id: PropTypes.string.isRequired,
|
|
408
|
-
journey_name: PropTypes.string.isRequired,
|
|
409
|
-
segments: PropTypes.arrayOf(
|
|
410
|
-
PropTypes.shape({
|
|
411
|
-
arc: PropTypes.bool,
|
|
412
|
-
from: transitivePlaceType,
|
|
413
|
-
patterns: PropTypes.arrayOf(
|
|
414
|
-
PropTypes.shape({
|
|
415
|
-
pattern_id: PropTypes.string.isRequired,
|
|
416
|
-
from_stop_index: PropTypes.number.isRequired,
|
|
417
|
-
to_stop_index: PropTypes.number.isRequired
|
|
418
|
-
})
|
|
419
|
-
),
|
|
420
|
-
streetEdges: PropTypes.arrayOf(PropTypes.number),
|
|
421
|
-
to: transitivePlaceType,
|
|
422
|
-
type: PropTypes.string.isRequired
|
|
423
|
-
})
|
|
424
|
-
).isRequired
|
|
425
|
-
})
|
|
426
|
-
).isRequired,
|
|
427
|
-
patterns: PropTypes.arrayOf(
|
|
428
|
-
PropTypes.shape({
|
|
429
|
-
pattern_id: PropTypes.string.isRequired,
|
|
430
|
-
pattern_name: PropTypes.string.isRequired,
|
|
431
|
-
route_id: PropTypes.string.isRequired,
|
|
432
|
-
stops: PropTypes.arrayOf(
|
|
433
|
-
PropTypes.shape({
|
|
434
|
-
geometry: PropTypes.string,
|
|
435
|
-
stop_id: PropTypes.string.isRequired
|
|
436
|
-
})
|
|
437
|
-
).isRequired
|
|
438
|
-
})
|
|
439
|
-
).isRequired,
|
|
440
|
-
places: PropTypes.arrayOf(
|
|
441
|
-
PropTypes.shape({
|
|
442
|
-
place_id: PropTypes.string.isRequired,
|
|
443
|
-
place_lat: PropTypes.number.isRequired,
|
|
444
|
-
place_lon: PropTypes.number.isRequired,
|
|
445
|
-
place_name: PropTypes.string
|
|
446
|
-
})
|
|
447
|
-
).isRequired,
|
|
448
|
-
routes: PropTypes.arrayOf(
|
|
449
|
-
PropTypes.shape({
|
|
450
|
-
agency_id: PropTypes.string.isRequired,
|
|
451
|
-
route_id: PropTypes.string.isRequired,
|
|
452
|
-
route_short_name: PropTypes.string.isRequired,
|
|
453
|
-
route_long_name: PropTypes.string.isRequired,
|
|
454
|
-
route_type: PropTypes.number.isRequired,
|
|
455
|
-
route_color: PropTypes.string
|
|
456
|
-
})
|
|
457
|
-
).isRequired,
|
|
458
|
-
stops: PropTypes.arrayOf(
|
|
459
|
-
PropTypes.shape({
|
|
460
|
-
stop_id: PropTypes.string.isRequired,
|
|
461
|
-
stop_name: PropTypes.string.isRequired,
|
|
462
|
-
stop_lat: PropTypes.number.isRequired,
|
|
463
|
-
stop_lon: PropTypes.number.isRequired
|
|
464
|
-
})
|
|
465
|
-
).isRequired,
|
|
466
|
-
streetEdges: PropTypes.arrayOf(
|
|
467
|
-
PropTypes.shape({
|
|
468
|
-
edge_id: PropTypes.number.isRequired,
|
|
469
|
-
geometry: encodedPolylineType
|
|
470
|
-
})
|
|
471
|
-
).isRequired
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* This models data about a vehicle rental station as obtained from various
|
|
476
|
-
* vehicle rental API endpoints from OTP.
|
|
477
|
-
*/
|
|
478
|
-
export const stationType = PropTypes.shape({
|
|
479
|
-
bikesAvailable: PropTypes.number,
|
|
480
|
-
id: PropTypes.string.isRequired,
|
|
481
|
-
isFloatingBike: PropTypes.bool,
|
|
482
|
-
isFloatingCar: PropTypes.bool,
|
|
483
|
-
isFloatingVehicle: PropTypes.bool,
|
|
484
|
-
name: PropTypes.string,
|
|
485
|
-
networks: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
|
|
486
|
-
spacesAvailable: PropTypes.number,
|
|
487
|
-
x: PropTypes.number.isRequired,
|
|
488
|
-
y: PropTypes.number.isRequired
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Utility function to help create chained validators
|
|
493
|
-
* per https://www.ian-thomas.net/custom-proptype-validation-with-react/
|
|
494
|
-
* @param {*} validator The validator to use.
|
|
495
|
-
*/
|
|
496
|
-
export function createChainableTypeChecker(validator) {
|
|
497
|
-
function checkType(isRequired, props, propName, componentName, location) {
|
|
498
|
-
componentName = componentName || "ANONYMOUS";
|
|
499
|
-
if (props[propName] == null) {
|
|
500
|
-
if (isRequired) {
|
|
501
|
-
const locationName = ReactPropTypeLocationNames[location];
|
|
502
|
-
return new Error(
|
|
503
|
-
`Required '${locationName}/${propName}' was not specified in '${componentName}'.`
|
|
504
|
-
);
|
|
505
|
-
}
|
|
506
|
-
return null;
|
|
507
|
-
}
|
|
508
|
-
return validator(props, propName, componentName, location);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
const chainedCheckType = checkType.bind(null, false);
|
|
512
|
-
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
513
|
-
|
|
514
|
-
return chainedCheckType;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
export const latlngType = createChainableTypeChecker((props, propName) => {
|
|
518
|
-
// Source: https://reactjs.org/docs/typechecking-with-proptypes.html#react.proptypes
|
|
519
|
-
if (!isValidLatLng(props[propName])) {
|
|
520
|
-
return new Error(`${propName} needs to be a [lat, lng] array`);
|
|
521
|
-
}
|
|
522
|
-
return null;
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
export const modeOptionType = PropTypes.shape({
|
|
526
|
-
id: PropTypes.string.isRequired,
|
|
527
|
-
selected: PropTypes.bool,
|
|
528
|
-
showTitle: PropTypes.bool,
|
|
529
|
-
text: PropTypes.node.isRequired,
|
|
530
|
-
title: PropTypes.string
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
export const modeSelectorOptionsType = PropTypes.shape({
|
|
534
|
-
primary: modeOptionType,
|
|
535
|
-
secondary: PropTypes.arrayOf(modeOptionType),
|
|
536
|
-
tertiary: PropTypes.arrayOf(modeOptionType)
|
|
537
|
-
});
|
|
538
|
-
|
|
539
|
-
export const configuredModeType = PropTypes.oneOfType([
|
|
540
|
-
PropTypes.string,
|
|
541
|
-
PropTypes.shape({
|
|
542
|
-
mode: PropTypes.string.isRequired,
|
|
543
|
-
label: PropTypes.string.isRequired,
|
|
544
|
-
company: PropTypes.string
|
|
545
|
-
})
|
|
546
|
-
]);
|
|
547
|
-
|
|
548
|
-
export const configuredModesType = PropTypes.shape({
|
|
549
|
-
transitModes: PropTypes.arrayOf(configuredModeType),
|
|
550
|
-
accessModes: PropTypes.arrayOf(configuredModeType),
|
|
551
|
-
exclusiveModes: PropTypes.arrayOf(configuredModeType),
|
|
552
|
-
bicycleModes: PropTypes.arrayOf(configuredModeType),
|
|
553
|
-
micromobilityModes: PropTypes.arrayOf(configuredModeType)
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
export const configuredCompanyType = PropTypes.shape({
|
|
557
|
-
/**
|
|
558
|
-
* The id of the company. This is typically in all-caps.
|
|
559
|
-
*/
|
|
560
|
-
id: PropTypes.string.isRequired,
|
|
561
|
-
/**
|
|
562
|
-
* A human readable text value that can be displayed to users.
|
|
563
|
-
*/
|
|
564
|
-
label: PropTypes.string.isRequired,
|
|
565
|
-
/**
|
|
566
|
-
* A comma-separated list of applicable modes of travel that the company
|
|
567
|
-
* offers.
|
|
568
|
-
*/
|
|
569
|
-
modes: PropTypes.string.isRequired
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* Depending on the geocoder that is used, more properties than just the `label`
|
|
574
|
-
* property might be provided by the geocoder. For example, with the Pelias
|
|
575
|
-
* geocoder, properties such as `id`, `layer`, `source` are also included.
|
|
576
|
-
*/
|
|
577
|
-
export const geocodedFeatureType = PropTypes.shape({
|
|
578
|
-
geometry: PropTypes.shape({
|
|
579
|
-
coordinates: PropTypes.arrayOf(PropTypes.number.isRequired).isRequired,
|
|
580
|
-
type: PropTypes.string.isRequired
|
|
581
|
-
}).isRequired,
|
|
582
|
-
properties: PropTypes.shape({
|
|
583
|
-
label: PropTypes.string.isRequired
|
|
584
|
-
}).isRequired
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
export const userLocationType = PropTypes.shape({
|
|
588
|
-
id: PropTypes.string,
|
|
589
|
-
/**
|
|
590
|
-
* Can be either 'home', 'work', or null
|
|
591
|
-
*/
|
|
592
|
-
icon: PropTypes.string,
|
|
593
|
-
lat: PropTypes.number.isRequired,
|
|
594
|
-
lon: PropTypes.number.isRequired,
|
|
595
|
-
name: PropTypes.string.isRequired,
|
|
596
|
-
/**
|
|
597
|
-
* This represents the last time that this location was selected in a
|
|
598
|
-
* search
|
|
599
|
-
*/
|
|
600
|
-
timestamp: PropTypes.number,
|
|
601
|
-
/**
|
|
602
|
-
* One of: 'home', 'work', 'stop' or 'recent'
|
|
603
|
-
*/
|
|
604
|
-
type: PropTypes.string.isRequired
|
|
605
|
-
});
|