@travelswitchhq/flight-search-react 1.0.6 → 1.0.8
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/dist/index.cjs +40 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +40 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -195,6 +195,18 @@ var flightSearchWidgetStyles = `
|
|
|
195
195
|
min-width: 0;
|
|
196
196
|
overflow: visible;
|
|
197
197
|
}
|
|
198
|
+
.sw-form-field.sw-is-invalid {
|
|
199
|
+
box-shadow: inset 0 0 0 1px var(--sw-error);
|
|
200
|
+
}
|
|
201
|
+
.sw-form-field.sw-is-invalid label {
|
|
202
|
+
color: var(--sw-error);
|
|
203
|
+
}
|
|
204
|
+
.sw-custom-dropdown.sw-has-error .sw-custom-dropdown-trigger {
|
|
205
|
+
color: var(--sw-error);
|
|
206
|
+
}
|
|
207
|
+
.sw-custom-dropdown.sw-has-error .sw-custom-dropdown-trigger::placeholder {
|
|
208
|
+
color: var(--sw-error) !important;
|
|
209
|
+
}
|
|
198
210
|
.sw-form-field label {
|
|
199
211
|
display: block;
|
|
200
212
|
width: 100%;
|
|
@@ -1510,6 +1522,8 @@ function FlightSearchWidget({
|
|
|
1510
1522
|
const roomsGuestsMenuRef = (0, import_react.useRef)(null);
|
|
1511
1523
|
const dateRangeCalendarRef = (0, import_react.useRef)(null);
|
|
1512
1524
|
const mobileDateRangeCalendarRef = (0, import_react.useRef)(null);
|
|
1525
|
+
const oneWayDesktopCalendarRef = (0, import_react.useRef)(null);
|
|
1526
|
+
const oneWayMobileCalendarRef = (0, import_react.useRef)(null);
|
|
1513
1527
|
const segmentCalendarRefs = (0, import_react.useRef)({});
|
|
1514
1528
|
const getMaxSegments = () => {
|
|
1515
1529
|
if (tripType === "custom-search") return 3;
|
|
@@ -1615,8 +1629,12 @@ function FlightSearchWidget({
|
|
|
1615
1629
|
}
|
|
1616
1630
|
return updated;
|
|
1617
1631
|
});
|
|
1632
|
+
setValidationErrors((prev) => ({
|
|
1633
|
+
...prev,
|
|
1634
|
+
[segmentIndex]: { ...prev[segmentIndex] ?? {}, [dropdownType]: false }
|
|
1635
|
+
}));
|
|
1618
1636
|
closeAirportDropdown(dropdownType, segmentIndex);
|
|
1619
|
-
}, [closeAirportDropdown]);
|
|
1637
|
+
}, [closeAirportDropdown, tripType]);
|
|
1620
1638
|
const updateSelectedIndex = (0, import_react.useCallback)((segmentIndex, dropdownType, newIndex) => {
|
|
1621
1639
|
setPredictiveSearchList((prev) => {
|
|
1622
1640
|
const state = prev[segmentIndex] ?? { fromAirport: [], toAirport: [], selectedFromIndex: -1, selectedToIndex: -1 };
|
|
@@ -2037,6 +2055,14 @@ function FlightSearchWidget({
|
|
|
2037
2055
|
queryStringObj[`umrah`] = isUmrahFareOption();
|
|
2038
2056
|
return queryStringObj;
|
|
2039
2057
|
};
|
|
2058
|
+
const getNormalizedRedirectionBase = () => {
|
|
2059
|
+
const raw = (redirectionDomain ?? "").trim();
|
|
2060
|
+
if (!raw) return null;
|
|
2061
|
+
if (raw.startsWith("http://") || raw.startsWith("https://")) {
|
|
2062
|
+
return raw.replace(/\/+$/, "");
|
|
2063
|
+
}
|
|
2064
|
+
return `https://${raw.replace(/\/+$/, "")}`;
|
|
2065
|
+
};
|
|
2040
2066
|
const handleSearch = () => {
|
|
2041
2067
|
const queryStringObj = createQueryString();
|
|
2042
2068
|
console.log("Query String Object:", queryStringObj);
|
|
@@ -2056,8 +2082,9 @@ function FlightSearchWidget({
|
|
|
2056
2082
|
}
|
|
2057
2083
|
const queryString = queryParams.toString();
|
|
2058
2084
|
console.log("Query String:", queryString);
|
|
2059
|
-
|
|
2060
|
-
|
|
2085
|
+
const base = getNormalizedRedirectionBase();
|
|
2086
|
+
if (base) {
|
|
2087
|
+
const url = `${base}/flight/listing?${queryString}`;
|
|
2061
2088
|
window.location.href = url;
|
|
2062
2089
|
}
|
|
2063
2090
|
};
|
|
@@ -2395,17 +2422,19 @@ function FlightSearchWidget({
|
|
|
2395
2422
|
{
|
|
2396
2423
|
className: "sw-form-field sw-pos-rel sw-com-cal",
|
|
2397
2424
|
style: { cursor: "pointer" },
|
|
2398
|
-
onClick: () =>
|
|
2425
|
+
onClick: () => {
|
|
2426
|
+
oneWayDesktopCalendarRef.current?.show?.();
|
|
2427
|
+
oneWayMobileCalendarRef.current?.show?.();
|
|
2428
|
+
},
|
|
2399
2429
|
children: [
|
|
2400
2430
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { children: "Departure" }),
|
|
2401
2431
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: formatDisplayDate(segments[0]?.departureDate) }),
|
|
2402
2432
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2403
2433
|
import_calendar.Calendar,
|
|
2404
2434
|
{
|
|
2435
|
+
id: "oneWayDepartureDesktop",
|
|
2405
2436
|
numberOfMonths: 2,
|
|
2406
|
-
ref:
|
|
2407
|
-
segmentCalendarRefs.current[0] = el;
|
|
2408
|
-
},
|
|
2437
|
+
ref: oneWayDesktopCalendarRef,
|
|
2409
2438
|
value: segments[0]?.departureDate ?? null,
|
|
2410
2439
|
onChange: (e) => {
|
|
2411
2440
|
const raw = e.value;
|
|
@@ -2425,10 +2454,9 @@ function FlightSearchWidget({
|
|
|
2425
2454
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2426
2455
|
import_calendar.Calendar,
|
|
2427
2456
|
{
|
|
2457
|
+
id: "oneWayDepartureMobile",
|
|
2428
2458
|
numberOfMonths: 10,
|
|
2429
|
-
ref:
|
|
2430
|
-
segmentCalendarRefs.current[0] = el;
|
|
2431
|
-
},
|
|
2459
|
+
ref: oneWayMobileCalendarRef,
|
|
2432
2460
|
value: segments[0]?.departureDate ?? null,
|
|
2433
2461
|
onChange: (e) => {
|
|
2434
2462
|
const raw = e.value;
|
|
@@ -2446,7 +2474,7 @@ function FlightSearchWidget({
|
|
|
2446
2474
|
headerTemplate: () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mobileHead MobileShow", children: [
|
|
2447
2475
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { type: "button", onClick: (e) => {
|
|
2448
2476
|
e.stopPropagation();
|
|
2449
|
-
|
|
2477
|
+
oneWayMobileCalendarRef.current?.hide?.();
|
|
2450
2478
|
}, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "20px", height: "20px", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
2451
2479
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M19 5L5 19", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
2452
2480
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 5L19 19", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
@@ -2460,7 +2488,7 @@ function FlightSearchWidget({
|
|
|
2460
2488
|
className: "sw-confirm-btn",
|
|
2461
2489
|
onClick: (e) => {
|
|
2462
2490
|
e.stopPropagation();
|
|
2463
|
-
|
|
2491
|
+
oneWayMobileCalendarRef.current?.hide?.();
|
|
2464
2492
|
},
|
|
2465
2493
|
children: "Confirm"
|
|
2466
2494
|
}
|