@travelswitchhq/flight-search-react 1.1.0 → 1.1.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/dist/index.cjs +48 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +48 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1113,6 +1113,9 @@ padding-inline-start: 25px;
|
|
|
1113
1113
|
font-size: 14px;
|
|
1114
1114
|
line-height: 1;
|
|
1115
1115
|
}
|
|
1116
|
+
.sw-container .sw-is-invalid{
|
|
1117
|
+
border: 1px solid var(--sw-error);
|
|
1118
|
+
}
|
|
1116
1119
|
.sw-checkbox-wrap .sw-star-checkbox {
|
|
1117
1120
|
display: flex;
|
|
1118
1121
|
align-items: center;
|
|
@@ -1183,6 +1186,7 @@ padding-inline-start: 25px;
|
|
|
1183
1186
|
display: none;
|
|
1184
1187
|
}
|
|
1185
1188
|
}
|
|
1189
|
+
|
|
1186
1190
|
.sw-container .sw-form-field {
|
|
1187
1191
|
border-radius: var(--sw-radius);
|
|
1188
1192
|
}
|
|
@@ -1252,6 +1256,7 @@ padding-inline-start: 25px;
|
|
|
1252
1256
|
width: 100%;
|
|
1253
1257
|
max-height: 100vh;
|
|
1254
1258
|
overflow: auto;
|
|
1259
|
+
display: block !important;
|
|
1255
1260
|
-webkit-overflow-scrolling: touch;
|
|
1256
1261
|
scroll-behavior: smooth;
|
|
1257
1262
|
padding: 0 !important;
|
|
@@ -1645,6 +1650,23 @@ function FlightSearchWidget({
|
|
|
1645
1650
|
[segmentIndex]: { ...prev[segmentIndex] ?? {}, [dropdownType]: false }
|
|
1646
1651
|
}));
|
|
1647
1652
|
closeAirportDropdown(dropdownType, segmentIndex);
|
|
1653
|
+
setValidationErrors((prev) => {
|
|
1654
|
+
const next = { ...prev };
|
|
1655
|
+
const clearForSegment = (segIndex, type) => {
|
|
1656
|
+
const segErr = next[segIndex];
|
|
1657
|
+
if (!segErr) return;
|
|
1658
|
+
const updatedSegErr = { ...segErr };
|
|
1659
|
+
if (type === "origin") delete updatedSegErr.origin;
|
|
1660
|
+
else delete updatedSegErr.destination;
|
|
1661
|
+
if (Object.keys(updatedSegErr).length === 0) delete next[segIndex];
|
|
1662
|
+
else next[segIndex] = updatedSegErr;
|
|
1663
|
+
};
|
|
1664
|
+
clearForSegment(segmentIndex, dropdownType);
|
|
1665
|
+
if ((tripType === "multi-city" || tripType === "custom-search") && dropdownType === "destination") {
|
|
1666
|
+
clearForSegment(segmentIndex + 1, "origin");
|
|
1667
|
+
}
|
|
1668
|
+
return next;
|
|
1669
|
+
});
|
|
1648
1670
|
}, [closeAirportDropdown, tripType]);
|
|
1649
1671
|
const updateSelectedIndex = (0, import_react.useCallback)((segmentIndex, dropdownType, newIndex) => {
|
|
1650
1672
|
setPredictiveSearchList((prev) => {
|
|
@@ -1878,19 +1900,6 @@ function FlightSearchWidget({
|
|
|
1878
1900
|
}
|
|
1879
1901
|
return updated;
|
|
1880
1902
|
});
|
|
1881
|
-
if (field === "origin" || field === "destination") {
|
|
1882
|
-
setSegmentDropdowns((prev) => ({
|
|
1883
|
-
...prev,
|
|
1884
|
-
[index]: { ...prev[index], [field]: false }
|
|
1885
|
-
}));
|
|
1886
|
-
const placeholder = field === "origin" ? "Origin" : "Destination";
|
|
1887
|
-
if (isValidLocationValue(value, placeholder)) {
|
|
1888
|
-
setValidationErrors((prev) => ({
|
|
1889
|
-
...prev,
|
|
1890
|
-
[index]: { ...prev[index] ?? {}, [field]: false }
|
|
1891
|
-
}));
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
1903
|
};
|
|
1895
1904
|
const handleTravellerChange = (field, value) => {
|
|
1896
1905
|
setSegments((prev) => {
|
|
@@ -1901,13 +1910,25 @@ function FlightSearchWidget({
|
|
|
1901
1910
|
});
|
|
1902
1911
|
};
|
|
1903
1912
|
const toggleSegmentDropdown = (index, field) => {
|
|
1904
|
-
setSegmentDropdowns((prev) =>
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1913
|
+
setSegmentDropdowns((prev) => {
|
|
1914
|
+
const shouldOpen = !prev[index]?.[field];
|
|
1915
|
+
if (!shouldOpen) {
|
|
1916
|
+
return {
|
|
1917
|
+
...prev,
|
|
1918
|
+
[index]: {
|
|
1919
|
+
...prev[index] || { origin: false, destination: false },
|
|
1920
|
+
[field]: false
|
|
1921
|
+
}
|
|
1922
|
+
};
|
|
1909
1923
|
}
|
|
1910
|
-
|
|
1924
|
+
const next = {};
|
|
1925
|
+
Object.keys(prev).forEach((key) => {
|
|
1926
|
+
const idx = Number.parseInt(key, 10);
|
|
1927
|
+
next[idx] = { origin: false, destination: false };
|
|
1928
|
+
});
|
|
1929
|
+
next[index] = { origin: false, destination: false, [field]: true };
|
|
1930
|
+
return next;
|
|
1931
|
+
});
|
|
1911
1932
|
};
|
|
1912
1933
|
const swapSegmentLocations = (index) => {
|
|
1913
1934
|
setSegments((prev) => {
|
|
@@ -2160,7 +2181,7 @@ function FlightSearchWidget({
|
|
|
2160
2181
|
] }) }),
|
|
2161
2182
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: isOrigin ? "Origin" : "Destination" })
|
|
2162
2183
|
] }),
|
|
2163
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mobileSrgInput MobileShow", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "
|
|
2184
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mobileSrgInput MobileShow", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "search", placeholder: `Search ${isOrigin ? "Origin" : "Destination"}`, value: value ?? "", onChange: (e) => {
|
|
2164
2185
|
const val = e.target.value;
|
|
2165
2186
|
handleSegmentFieldChange(segmentIndex, dropdownType, val);
|
|
2166
2187
|
triggerSearchAirport(segmentIndex, dropdownType, val);
|
|
@@ -2222,6 +2243,7 @@ function FlightSearchWidget({
|
|
|
2222
2243
|
numberOfMonths: 2,
|
|
2223
2244
|
id: `departure-${index}`,
|
|
2224
2245
|
appendTo: "self",
|
|
2246
|
+
readOnlyInput: true,
|
|
2225
2247
|
value: segment.departureDate ?? null,
|
|
2226
2248
|
onChange: (e) => {
|
|
2227
2249
|
const raw = e.value;
|
|
@@ -2244,6 +2266,10 @@ function FlightSearchWidget({
|
|
|
2244
2266
|
numberOfMonths: 10,
|
|
2245
2267
|
id: `departure-${index}`,
|
|
2246
2268
|
appendTo: "self",
|
|
2269
|
+
ref: (el) => {
|
|
2270
|
+
segmentCalendarRefs.current[index] = el;
|
|
2271
|
+
},
|
|
2272
|
+
readOnlyInput: true,
|
|
2247
2273
|
value: segment.departureDate ?? null,
|
|
2248
2274
|
onChange: (e) => {
|
|
2249
2275
|
const raw = e.value;
|
|
@@ -2261,7 +2287,7 @@ function FlightSearchWidget({
|
|
|
2261
2287
|
headerTemplate: () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mobileHead MobileShow", children: [
|
|
2262
2288
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { type: "button", onClick: (e) => {
|
|
2263
2289
|
e.stopPropagation();
|
|
2264
|
-
|
|
2290
|
+
segmentCalendarRefs.current[index]?.hide?.();
|
|
2265
2291
|
}, 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: [
|
|
2266
2292
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M19 5L5 19", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
2267
2293
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 5L19 19", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
@@ -2275,7 +2301,7 @@ function FlightSearchWidget({
|
|
|
2275
2301
|
className: "sw-confirm-btn",
|
|
2276
2302
|
onClick: (e) => {
|
|
2277
2303
|
e.stopPropagation();
|
|
2278
|
-
|
|
2304
|
+
segmentCalendarRefs.current[index]?.hide?.();
|
|
2279
2305
|
},
|
|
2280
2306
|
children: "Confirm"
|
|
2281
2307
|
}
|