related-ui-components 2.7.5 → 2.7.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/lib/module/app.js +4 -29
- package/lib/module/app.js.map +1 -1
- package/lib/module/components/TravelBooking/FlightSummary.js +219 -112
- package/lib/module/components/TravelBooking/FlightSummary.js.map +1 -1
- package/lib/module/components/TravelBooking/SummaryBar.js +239 -172
- package/lib/module/components/TravelBooking/SummaryBar.js.map +1 -1
- package/lib/module/components/TravelBooking/TravelBooking.js +407 -241
- package/lib/module/components/TravelBooking/TravelBooking.js.map +1 -1
- package/lib/module/components/TravelBooking/index.js +5 -4
- package/lib/module/components/TravelBooking/index.js.map +1 -1
- package/lib/typescript/src/components/TravelBooking/FlightSummary.d.ts +25 -11
- package/lib/typescript/src/components/TravelBooking/FlightSummary.d.ts.map +1 -1
- package/lib/typescript/src/components/TravelBooking/SummaryBar.d.ts +1 -16
- package/lib/typescript/src/components/TravelBooking/SummaryBar.d.ts.map +1 -1
- package/lib/typescript/src/components/TravelBooking/TravelBooking.d.ts +1 -83
- package/lib/typescript/src/components/TravelBooking/TravelBooking.d.ts.map +1 -1
- package/lib/typescript/src/components/TravelBooking/index.d.ts +0 -4
- package/lib/typescript/src/components/TravelBooking/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/app.tsx +3 -3
- package/src/components/TravelBooking/FlightSummary.tsx +264 -164
- package/src/components/TravelBooking/SummaryBar.tsx +239 -239
- package/src/components/TravelBooking/TravelBooking.tsx +407 -407
- package/src/components/TravelBooking/index.ts +4 -4
- package/src/index.ts +1 -1
|
@@ -1,407 +1,407 @@
|
|
|
1
|
-
// src/components/TravelBooking.tsx (or wherever TravelBooking is)
|
|
2
|
-
import React, { useState, useCallback, useMemo, useEffect } from "react";
|
|
3
|
-
import { View, StyleSheet, StyleProp, ViewStyle, TextStyle } from "react-native"; // Import style types
|
|
4
|
-
import TabSelector, { TabSelectorProps } from "./TabSelector"; // Adjust import path
|
|
5
|
-
import FlightForm, { FlightFormProps } from "./FlightForm"; // Adjust import path
|
|
6
|
-
import HotelForm, { HotelFormProps } from "./HotelForm"; // Adjust import path
|
|
7
|
-
import CarRentalForm, {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "./CarRentalForm"; // Adjust import path
|
|
11
|
-
import { ThemeType, useTheme } from "../../theme"; // Adjust import path
|
|
12
|
-
import SummaryBar, {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from "./SummaryBar"; // Adjust import path
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} from "./types"; // Adjust import path
|
|
22
|
-
import { FlightSelection, FlightSummaryProps } from "./FlightSummary";
|
|
23
|
-
import { HotelSummaryProps, RoomState } from "./HotelSummary";
|
|
24
|
-
|
|
25
|
-
// Define the possible tab names (can be overridden via props)
|
|
26
|
-
type DefaultBookingType = "Flights" | "Hotels" | "Car Rentals";
|
|
27
|
-
const DEFAULT_TABS: DefaultBookingType[] = ["Flights", "Hotels", "Car Rentals"];
|
|
28
|
-
|
|
29
|
-
// Mock Data (Keep accessible for potential defaults)
|
|
30
|
-
const DEFAULT_MOCK_FLIGHT_SUGGESTIONS: FlightSuggestions[] = [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
];
|
|
52
|
-
const DEFAULT_MOCK_HOTEL_SUGGESTIONS: HotelSuggestions[] = [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
];
|
|
61
|
-
const DEFAULT_MOCK_CAR_SUGGESTIONS: CarSuggestions[] = mockCarSuggestions;
|
|
62
|
-
|
|
63
|
-
// --- TravelBooking Props Interface ---
|
|
64
|
-
export interface TravelBookingProps {
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// --- TravelBooking Component Implementation ---
|
|
175
|
-
const TravelBooking: React.FC<TravelBookingProps> = ({
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}) => {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
const themedStyles = (theme: ThemeType) =>
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
export default TravelBooking;
|
|
1
|
+
// // src/components/TravelBooking.tsx (or wherever TravelBooking is)
|
|
2
|
+
// import React, { useState, useCallback, useMemo, useEffect } from "react";
|
|
3
|
+
// import { View, StyleSheet, StyleProp, ViewStyle, TextStyle } from "react-native"; // Import style types
|
|
4
|
+
// import TabSelector, { TabSelectorProps } from "./TabSelector"; // Adjust import path
|
|
5
|
+
// import FlightForm, { FlightFormProps } from "./FlightForm"; // Adjust import path
|
|
6
|
+
// import HotelForm, { HotelFormProps } from "./HotelForm"; // Adjust import path
|
|
7
|
+
// import CarRentalForm, {
|
|
8
|
+
// CarRentalFormProps,
|
|
9
|
+
// mockCarSuggestions,
|
|
10
|
+
// } from "./CarRentalForm"; // Adjust import path
|
|
11
|
+
// import { ThemeType, useTheme } from "../../theme"; // Adjust import path
|
|
12
|
+
// import SummaryBar, {
|
|
13
|
+
// SelectionCallbackDataType,
|
|
14
|
+
// SummaryBarProps,
|
|
15
|
+
// } from "./SummaryBar"; // Adjust import path
|
|
16
|
+
// import {
|
|
17
|
+
// FlightSuggestions,
|
|
18
|
+
// FormInputType,
|
|
19
|
+
// HotelSuggestions,
|
|
20
|
+
// CarSuggestions,
|
|
21
|
+
// } from "./types"; // Adjust import path
|
|
22
|
+
// import { FlightSelection, FlightSummaryProps } from "./FlightSummary";
|
|
23
|
+
// import { HotelSummaryProps, RoomState } from "./HotelSummary";
|
|
24
|
+
|
|
25
|
+
// // Define the possible tab names (can be overridden via props)
|
|
26
|
+
// type DefaultBookingType = "Flights" | "Hotels" | "Car Rentals";
|
|
27
|
+
// const DEFAULT_TABS: DefaultBookingType[] = ["Flights", "Hotels", "Car Rentals"];
|
|
28
|
+
|
|
29
|
+
// // Mock Data (Keep accessible for potential defaults)
|
|
30
|
+
// const DEFAULT_MOCK_FLIGHT_SUGGESTIONS: FlightSuggestions[] = [
|
|
31
|
+
// {
|
|
32
|
+
// id: 1,
|
|
33
|
+
// city: "London",
|
|
34
|
+
// value: "London, United Kingdom",
|
|
35
|
+
// airports: [
|
|
36
|
+
// "Heathrow Airport (LHR)",
|
|
37
|
+
// "Gatwick Airport (LGW)",
|
|
38
|
+
// "Stansted Airport (STN)",
|
|
39
|
+
// ],
|
|
40
|
+
// },
|
|
41
|
+
// {
|
|
42
|
+
// id: 2,
|
|
43
|
+
// city: "New York",
|
|
44
|
+
// value: "New York, USA",
|
|
45
|
+
// airports: [
|
|
46
|
+
// "John F. Kennedy Intl (JFK)",
|
|
47
|
+
// "LaGuardia Airport (LGA)",
|
|
48
|
+
// "Newark Liberty Intl (EWR)",
|
|
49
|
+
// ],
|
|
50
|
+
// },
|
|
51
|
+
// ];
|
|
52
|
+
// const DEFAULT_MOCK_HOTEL_SUGGESTIONS: HotelSuggestions[] = [
|
|
53
|
+
// { id: 1, city: "Beirut", country: "Lebanon", value: "BEIRUT, LEBANON" },
|
|
54
|
+
// {
|
|
55
|
+
// id: 2,
|
|
56
|
+
// city: "Dubai",
|
|
57
|
+
// country: "United Arab Emirates",
|
|
58
|
+
// value: "DUBAI, UNITED ARAB EMIRATES",
|
|
59
|
+
// },
|
|
60
|
+
// ];
|
|
61
|
+
// const DEFAULT_MOCK_CAR_SUGGESTIONS: CarSuggestions[] = mockCarSuggestions;
|
|
62
|
+
|
|
63
|
+
// // --- TravelBooking Props Interface ---
|
|
64
|
+
// export interface TravelBookingProps {
|
|
65
|
+
// /** Array of tab names. Defaults to ['Flights', 'Hotels', 'Car Rentals'] */
|
|
66
|
+
// tabs?: string[];
|
|
67
|
+
// /** The initially selected tab. Defaults to the first tab in the `tabs` array. */
|
|
68
|
+
// initialTab?: string;
|
|
69
|
+
// /** Callback when the selected tab changes */
|
|
70
|
+
// onTabChange?: (tab: string) => void;
|
|
71
|
+
// /** Callback when the search button is pressed in any form */
|
|
72
|
+
// onSearch?: (details: any) => void;
|
|
73
|
+
// /** Callback when any form input gains focus */
|
|
74
|
+
// onInputFocus?: (input: FormInputType) => void;
|
|
75
|
+
// /** Callback when text changes in location inputs */
|
|
76
|
+
// onTextChange?: (text: string) => void;
|
|
77
|
+
|
|
78
|
+
// /** Initial selection state for FlightSummary (if mode is 'flight') */
|
|
79
|
+
// initialFlightSelection?: FlightSelection;
|
|
80
|
+
// /** Initial selection state for HotelSummary (if mode is 'hotel') */
|
|
81
|
+
// initialHotelSelection?: RoomState[];
|
|
82
|
+
// /** Callback when the selection in SummaryBar changes */
|
|
83
|
+
// onSummarySelectionChange?: (selection: SelectionCallbackDataType) => void;
|
|
84
|
+
|
|
85
|
+
// /** Suggestion data for FlightForm */
|
|
86
|
+
// flightSuggestionData?: FlightSuggestions[];
|
|
87
|
+
// /** Suggestion data for HotelForm */
|
|
88
|
+
// hotelSuggestionData?: HotelSuggestions[];
|
|
89
|
+
// /** Suggestion data for CarRentalForm */
|
|
90
|
+
// carSuggestionData?: CarSuggestions[];
|
|
91
|
+
|
|
92
|
+
// // --- Common Style Props ---
|
|
93
|
+
// /** Style for the root container of each form */
|
|
94
|
+
// formContainerStyle?: StyleProp<ViewStyle>;
|
|
95
|
+
// /** Style for input labels */
|
|
96
|
+
// labelStyle?: StyleProp<TextStyle>;
|
|
97
|
+
// /** Style for the CustomInput's TextInput component */
|
|
98
|
+
// inputStyle?: StyleProp<ViewStyle>; // Renamed from commonInputStyle for clarity
|
|
99
|
+
// /** Style for the touchable wrapper around date displays (if applicable) */
|
|
100
|
+
// inputTouchableStyle?: StyleProp<ViewStyle>;
|
|
101
|
+
// /** Style for the text inside inputs or date displays */
|
|
102
|
+
// inputTextStyle?: StyleProp<TextStyle>;
|
|
103
|
+
// /** Style for the container holding the date picker(s) and search button */
|
|
104
|
+
// dateSearchRowStyle?: StyleProp<ViewStyle>;
|
|
105
|
+
// /** Style for the individual date display groups within DateRangePicker */
|
|
106
|
+
// dateInputGroupStyle?: StyleProp<ViewStyle>;
|
|
107
|
+
// /** Style for the search button */
|
|
108
|
+
// searchButtonStyle?: StyleProp<ViewStyle>;
|
|
109
|
+
// /** Style for the search icon */
|
|
110
|
+
// searchIconStyle?: StyleProp<TextStyle>;
|
|
111
|
+
// /** Theme overrides for the calendar component */
|
|
112
|
+
// calendarThemeOverrides?: object;
|
|
113
|
+
// /** Style for the container wrapping the calendar modal/view */
|
|
114
|
+
// calendarContainerStyle?: StyleProp<ViewStyle>;
|
|
115
|
+
// /** Style for the container wrapping the swap button (Flights/Cars) */
|
|
116
|
+
// swapButtonContainerStyle?: StyleProp<ViewStyle>;
|
|
117
|
+
// /** Style for the swap button itself (Flights/Cars) */
|
|
118
|
+
// swapButtonStyle?: StyleProp<ViewStyle>;
|
|
119
|
+
// /** Style for the swap icon (Flights/Cars) */
|
|
120
|
+
// swapIconStyle?: StyleProp<TextStyle>;
|
|
121
|
+
// /** Style for the container wrapping the input fields (Flights/Cars) */
|
|
122
|
+
// inputGroupContainerStyle?: StyleProp<ViewStyle>; // Added for consistency
|
|
123
|
+
|
|
124
|
+
// // --- Nested Props for Child Components ---
|
|
125
|
+
|
|
126
|
+
// /** Props to pass down to the TabSelector component */
|
|
127
|
+
// tabSelectorProps?: Omit<
|
|
128
|
+
// TabSelectorProps,
|
|
129
|
+
// "tabs" | "initialTab" | "onTabChange" // Controlled by TravelBooking
|
|
130
|
+
// >;
|
|
131
|
+
|
|
132
|
+
// /** Props to pass down to the SummaryBar component */
|
|
133
|
+
// summaryBarProps?: Omit<
|
|
134
|
+
// SummaryBarProps,
|
|
135
|
+
// | "mode"
|
|
136
|
+
// | "initialSelection"
|
|
137
|
+
// | "onSelectionChange"
|
|
138
|
+
// | "flightProps"
|
|
139
|
+
// | "hotelProps" // Controlled or derived by TravelBooking
|
|
140
|
+
// >;
|
|
141
|
+
|
|
142
|
+
// /** Props to pass down to the FlightSummary component (via SummaryBar) */
|
|
143
|
+
// flightSummaryProps?: Omit<
|
|
144
|
+
// FlightSummaryProps,
|
|
145
|
+
// "selection" | "onSelectionChange" // Controlled by SummaryBar/TravelBooking
|
|
146
|
+
// >;
|
|
147
|
+
|
|
148
|
+
// /** Props to pass down to the HotelSummary component (via SummaryBar) */
|
|
149
|
+
// hotelSummaryProps?: Omit<
|
|
150
|
+
// HotelSummaryProps,
|
|
151
|
+
// "selection" | "onSelectionChange" // Controlled by SummaryBar/TravelBooking
|
|
152
|
+
// >;
|
|
153
|
+
|
|
154
|
+
// /** Props to pass down to the FlightForm component */
|
|
155
|
+
// /** Props to pass down to the FlightForm component */
|
|
156
|
+
// flightFormProps?: Omit<
|
|
157
|
+
// FlightFormProps,
|
|
158
|
+
// "isOneWay" | "onSearchPress" | "onInputFocus" | "suggestionData" | "onTextChange" // Controlled or derived by TravelBooking
|
|
159
|
+
// >;
|
|
160
|
+
|
|
161
|
+
// /** Props to pass down to the HotelForm component */
|
|
162
|
+
// hotelFormProps?: Omit<
|
|
163
|
+
// HotelFormProps,
|
|
164
|
+
// "onSearchPress" | "onInputFocus" | "suggestionData" | "onTextChange" // Controlled by TravelBooking
|
|
165
|
+
// >;
|
|
166
|
+
|
|
167
|
+
// /** Props to pass down to the CarRentalForm component */
|
|
168
|
+
// carRentalFormProps?: Omit<
|
|
169
|
+
// CarRentalFormProps,
|
|
170
|
+
// "onSearchPress" | "onInputFocus" | "suggestionData" | "onTextChange"// Controlled by TravelBooking
|
|
171
|
+
// >;
|
|
172
|
+
// }
|
|
173
|
+
|
|
174
|
+
// // --- TravelBooking Component Implementation ---
|
|
175
|
+
// const TravelBooking: React.FC<TravelBookingProps> = ({
|
|
176
|
+
// tabs = DEFAULT_TABS,
|
|
177
|
+
// initialTab,
|
|
178
|
+
// onTabChange,
|
|
179
|
+
// onSearch,
|
|
180
|
+
// initialFlightSelection,
|
|
181
|
+
// initialHotelSelection,
|
|
182
|
+
// onSummarySelectionChange,
|
|
183
|
+
// flightSuggestionData = DEFAULT_MOCK_FLIGHT_SUGGESTIONS, // Provide defaults
|
|
184
|
+
// hotelSuggestionData = DEFAULT_MOCK_HOTEL_SUGGESTIONS, // Provide defaults
|
|
185
|
+
// carSuggestionData = DEFAULT_MOCK_CAR_SUGGESTIONS, // Provide defaults
|
|
186
|
+
// tabSelectorProps,
|
|
187
|
+
// summaryBarProps,
|
|
188
|
+
// flightFormProps,
|
|
189
|
+
// hotelFormProps,
|
|
190
|
+
// carRentalFormProps,
|
|
191
|
+
// onInputFocus,
|
|
192
|
+
// onTextChange,
|
|
193
|
+
// // Destructure common style props
|
|
194
|
+
// formContainerStyle,
|
|
195
|
+
// labelStyle,
|
|
196
|
+
// inputStyle,
|
|
197
|
+
// inputTouchableStyle,
|
|
198
|
+
// inputTextStyle,
|
|
199
|
+
// dateSearchRowStyle,
|
|
200
|
+
// dateInputGroupStyle,
|
|
201
|
+
// searchButtonStyle,
|
|
202
|
+
// searchIconStyle,
|
|
203
|
+
// calendarThemeOverrides,
|
|
204
|
+
// calendarContainerStyle,
|
|
205
|
+
// swapButtonContainerStyle,
|
|
206
|
+
// swapButtonStyle,
|
|
207
|
+
// swapIconStyle,
|
|
208
|
+
// inputGroupContainerStyle, // Added
|
|
209
|
+
// }) => {
|
|
210
|
+
// const { theme } = useTheme();
|
|
211
|
+
// const styles = useMemo(() => themedStyles(theme), [theme]);
|
|
212
|
+
|
|
213
|
+
// const actualInitialTab = useMemo(
|
|
214
|
+
// () => initialTab ?? (tabs.length > 0 ? tabs[0] : ""),
|
|
215
|
+
// [initialTab, tabs]
|
|
216
|
+
// );
|
|
217
|
+
|
|
218
|
+
// const [selectedTab, setSelectedTab] = useState<string>(actualInitialTab);
|
|
219
|
+
// const [selectedOptions, setSelectedOptions] = useState<
|
|
220
|
+
// SelectionCallbackDataType | undefined
|
|
221
|
+
// >(
|
|
222
|
+
// actualInitialTab === tabs[0] && tabs[0] === "Flights"
|
|
223
|
+
// ? initialFlightSelection
|
|
224
|
+
// : actualInitialTab === tabs[1] && tabs[1] === "Hotels"
|
|
225
|
+
// ? initialHotelSelection
|
|
226
|
+
// : undefined
|
|
227
|
+
// );
|
|
228
|
+
|
|
229
|
+
// // --- Handlers ---
|
|
230
|
+
// const handleTabChange = useCallback(
|
|
231
|
+
// (tab: string) => {
|
|
232
|
+
// setSelectedTab(tab);
|
|
233
|
+
// if (tab === "Flights") {
|
|
234
|
+
// setSelectedOptions(initialFlightSelection);
|
|
235
|
+
// } else if (tab === "Hotels") {
|
|
236
|
+
// setSelectedOptions(initialHotelSelection);
|
|
237
|
+
// } else {
|
|
238
|
+
// setSelectedOptions(undefined);
|
|
239
|
+
// }
|
|
240
|
+
// onTabChange?.(tab);
|
|
241
|
+
// },
|
|
242
|
+
// [onTabChange, initialFlightSelection, initialHotelSelection]
|
|
243
|
+
// );
|
|
244
|
+
|
|
245
|
+
// const handleInternalSummarySelectionChange = useCallback(
|
|
246
|
+
// (selection: SelectionCallbackDataType) => {
|
|
247
|
+
// setSelectedOptions(selection);
|
|
248
|
+
// onSummarySelectionChange?.(selection);
|
|
249
|
+
// },
|
|
250
|
+
// [onSummarySelectionChange]
|
|
251
|
+
// );
|
|
252
|
+
|
|
253
|
+
// const handleInternalSearch = useCallback(
|
|
254
|
+
// (details: any) => {
|
|
255
|
+
// console.log("Internal Search Triggered:", details);
|
|
256
|
+
// onSearch?.(details);
|
|
257
|
+
// },
|
|
258
|
+
// [onSearch]
|
|
259
|
+
// );
|
|
260
|
+
|
|
261
|
+
// const handleInternalTextChange = useCallback(
|
|
262
|
+
// (text: string) => {
|
|
263
|
+
// onTextChange?.(text);
|
|
264
|
+
// },
|
|
265
|
+
// [onTextChange] // Added dependency
|
|
266
|
+
// );
|
|
267
|
+
|
|
268
|
+
// const handleInternalInputFocus = useCallback(
|
|
269
|
+
// (input: FormInputType) => {
|
|
270
|
+
// console.log("Input Focused:", input);
|
|
271
|
+
// onInputFocus?.(input);
|
|
272
|
+
// },
|
|
273
|
+
// [onInputFocus] // Added dependency
|
|
274
|
+
// );
|
|
275
|
+
|
|
276
|
+
// // Determine SummaryBar mode
|
|
277
|
+
// const summaryBarMode = useMemo(() => {
|
|
278
|
+
// if (selectedTab === "Flights") return "flight";
|
|
279
|
+
// if (selectedTab === "Hotels") return "hotel";
|
|
280
|
+
// return undefined;
|
|
281
|
+
// }, [selectedTab]);
|
|
282
|
+
|
|
283
|
+
// // --- Render Content Logic ---
|
|
284
|
+
// const renderContent = () => {
|
|
285
|
+
// const commonFormProps = {
|
|
286
|
+
// containerStyle: formContainerStyle,
|
|
287
|
+
// labelStyle: labelStyle,
|
|
288
|
+
// inputStyle: inputStyle,
|
|
289
|
+
// inputTouchableStyle: inputTouchableStyle,
|
|
290
|
+
// inputTextStyle: inputTextStyle,
|
|
291
|
+
// dateInputGroupStyle: dateInputGroupStyle,
|
|
292
|
+
// searchButtonStyle: searchButtonStyle,
|
|
293
|
+
// searchIconStyle: searchIconStyle,
|
|
294
|
+
// calendarThemeOverrides: calendarThemeOverrides,
|
|
295
|
+
// calendarContainerStyle: calendarContainerStyle,
|
|
296
|
+
// };
|
|
297
|
+
|
|
298
|
+
// switch (selectedTab) {
|
|
299
|
+
// case "Flights": {
|
|
300
|
+
// let isOneWay = false;
|
|
301
|
+
// if (
|
|
302
|
+
// selectedOptions &&
|
|
303
|
+
// typeof selectedOptions === "object" &&
|
|
304
|
+
// !Array.isArray(selectedOptions) &&
|
|
305
|
+
// "flightType" in selectedOptions
|
|
306
|
+
// ) {
|
|
307
|
+
// isOneWay = selectedOptions.flightType === "ONE_WAY";
|
|
308
|
+
// }
|
|
309
|
+
// return (
|
|
310
|
+
// <FlightForm
|
|
311
|
+
// // Pass common props first
|
|
312
|
+
// {...commonFormProps}
|
|
313
|
+
// departureRowStyle={dateSearchRowStyle} // Map specific row style
|
|
314
|
+
// swapButtonContainerStyle={swapButtonContainerStyle} // Pass swap styles
|
|
315
|
+
// swapButtonStyle={swapButtonStyle}
|
|
316
|
+
// swapIconStyle={swapIconStyle}
|
|
317
|
+
|
|
318
|
+
// // Pass specific FlightForm props (will override common ones if keys match)
|
|
319
|
+
// {...flightFormProps}
|
|
320
|
+
|
|
321
|
+
// // Pass controlled props
|
|
322
|
+
// isOneWay={isOneWay}
|
|
323
|
+
// onSearchPress={handleInternalSearch}
|
|
324
|
+
// onInputFocus={handleInternalInputFocus}
|
|
325
|
+
// onTextChange={handleInternalTextChange}
|
|
326
|
+
// suggestionData={flightSuggestionData}
|
|
327
|
+
// />
|
|
328
|
+
// );
|
|
329
|
+
// }
|
|
330
|
+
// case "Hotels":
|
|
331
|
+
// return (
|
|
332
|
+
// <HotelForm
|
|
333
|
+
// // Pass common props first
|
|
334
|
+
// {...commonFormProps}
|
|
335
|
+
// checkoutRowStyle={dateSearchRowStyle} // Map specific row style
|
|
336
|
+
|
|
337
|
+
// // Pass specific HotelForm props (will override common ones if keys match)
|
|
338
|
+
// {...hotelFormProps}
|
|
339
|
+
|
|
340
|
+
// // Pass controlled props
|
|
341
|
+
// onSearchPress={handleInternalSearch}
|
|
342
|
+
// onInputFocus={handleInternalInputFocus}
|
|
343
|
+
// onTextChange={handleInternalTextChange}
|
|
344
|
+
// suggestionData={hotelSuggestionData}
|
|
345
|
+
// />
|
|
346
|
+
// );
|
|
347
|
+
// case "Car Rentals":
|
|
348
|
+
// return (
|
|
349
|
+
// <CarRentalForm
|
|
350
|
+
// // Pass common props first
|
|
351
|
+
// {...commonFormProps}
|
|
352
|
+
// pickupRowStyle={dateSearchRowStyle} // Map specific row style
|
|
353
|
+
// swapButtonContainerStyle={swapButtonContainerStyle} // Pass swap styles
|
|
354
|
+
// swapButtonStyle={swapButtonStyle}
|
|
355
|
+
// swapIconStyle={swapIconStyle}
|
|
356
|
+
// inputGroupStyle={inputGroupContainerStyle} // Map input group style
|
|
357
|
+
|
|
358
|
+
// // Pass specific CarRentalForm props (will override common ones if keys match)
|
|
359
|
+
// {...carRentalFormProps}
|
|
360
|
+
|
|
361
|
+
// // Pass controlled props
|
|
362
|
+
// onSearchPress={handleInternalSearch}
|
|
363
|
+
// onInputFocus={handleInternalInputFocus}
|
|
364
|
+
// onTextChange={handleInternalTextChange}
|
|
365
|
+
// suggestionData={carSuggestionData}
|
|
366
|
+
// />
|
|
367
|
+
// );
|
|
368
|
+
// default:
|
|
369
|
+
// console.warn(`No content defined for tab: ${selectedTab}`);
|
|
370
|
+
// return null;
|
|
371
|
+
// }
|
|
372
|
+
// };
|
|
373
|
+
|
|
374
|
+
// return (
|
|
375
|
+
// <View style={styles.container}>
|
|
376
|
+
// {/* Conditionally render SummaryBar */}
|
|
377
|
+
// {summaryBarMode && (
|
|
378
|
+
// <SummaryBar
|
|
379
|
+
// {...summaryBarProps}
|
|
380
|
+
// mode={summaryBarMode}
|
|
381
|
+
// onSelectionChange={handleInternalSummarySelectionChange}
|
|
382
|
+
// />
|
|
383
|
+
// )}
|
|
384
|
+
|
|
385
|
+
// <TabSelector
|
|
386
|
+
// {...tabSelectorProps}
|
|
387
|
+
// tabs={tabs}
|
|
388
|
+
// initialTab={selectedTab} // Use state for controlled component
|
|
389
|
+
// onTabChange={handleTabChange}
|
|
390
|
+
// />
|
|
391
|
+
|
|
392
|
+
// <View style={styles.contentContainer}>{renderContent()}</View>
|
|
393
|
+
// </View>
|
|
394
|
+
// );
|
|
395
|
+
// };
|
|
396
|
+
|
|
397
|
+
// const themedStyles = (theme: ThemeType) =>
|
|
398
|
+
// StyleSheet.create({
|
|
399
|
+
// container: {
|
|
400
|
+
// // Removed flex: 1 to allow content to determine height naturally
|
|
401
|
+
// },
|
|
402
|
+
// contentContainer: {
|
|
403
|
+
// // Removed flex: 1
|
|
404
|
+
// },
|
|
405
|
+
// });
|
|
406
|
+
|
|
407
|
+
// export default TravelBooking;
|