@travelswitchhq/flight-search-react 1.1.3 → 1.1.4
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 +23 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +23 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1495,7 +1495,9 @@ function FlightSearchWidget({
|
|
|
1495
1495
|
const urls = API_URLS[env];
|
|
1496
1496
|
const airportSearchApiBaseUrl = urls.airport;
|
|
1497
1497
|
const airlineSearchApiBaseUrl = urls.airline;
|
|
1498
|
-
const
|
|
1498
|
+
const countryCodeConfig = (config?.countryCode ?? "").trim();
|
|
1499
|
+
const languageCodeConfig = (config?.languageCode ?? "").trim();
|
|
1500
|
+
const langCode = languageCodeConfig || "en";
|
|
1499
1501
|
const [airlineQuery, setAirlineQuery] = (0, import_react.useState)("");
|
|
1500
1502
|
const [airlineSuggestions, setAirlineSuggestions] = (0, import_react.useState)([]);
|
|
1501
1503
|
const [selectedAirlines, setSelectedAirlines] = (0, import_react.useState)([]);
|
|
@@ -1541,6 +1543,7 @@ function FlightSearchWidget({
|
|
|
1541
1543
|
const [isDestinationDropdownOpen, setIsDestinationDropdownOpen] = (0, import_react.useState)(false);
|
|
1542
1544
|
const [isRoomsGuestsMenuOpen, setIsRoomsGuestsMenuOpen] = (0, import_react.useState)(false);
|
|
1543
1545
|
const originDropdownRef = (0, import_react.useRef)(null);
|
|
1546
|
+
const firstOriginDesktopInputRef = (0, import_react.useRef)(null);
|
|
1544
1547
|
const destinationDropdownRef = (0, import_react.useRef)(null);
|
|
1545
1548
|
const roomsGuestsMenuRef = (0, import_react.useRef)(null);
|
|
1546
1549
|
const dateRangeCalendarRef = (0, import_react.useRef)(null);
|
|
@@ -1771,6 +1774,21 @@ function FlightSearchWidget({
|
|
|
1771
1774
|
ensureStylesInjected();
|
|
1772
1775
|
ensurePrimeIconsLoaded();
|
|
1773
1776
|
}, []);
|
|
1777
|
+
(0, import_react.useEffect)(() => {
|
|
1778
|
+
if (typeof window === "undefined") return;
|
|
1779
|
+
const focusFirstOrigin = () => {
|
|
1780
|
+
const desktop = firstOriginDesktopInputRef.current;
|
|
1781
|
+
desktop?.focus({ preventScroll: true });
|
|
1782
|
+
};
|
|
1783
|
+
let innerRaf = 0;
|
|
1784
|
+
const outerRaf = window.requestAnimationFrame(() => {
|
|
1785
|
+
innerRaf = window.requestAnimationFrame(focusFirstOrigin);
|
|
1786
|
+
});
|
|
1787
|
+
return () => {
|
|
1788
|
+
window.cancelAnimationFrame(outerRaf);
|
|
1789
|
+
if (innerRaf) window.cancelAnimationFrame(innerRaf);
|
|
1790
|
+
};
|
|
1791
|
+
}, []);
|
|
1774
1792
|
(0, import_react.useEffect)(() => {
|
|
1775
1793
|
const handleClickOutside = (event) => {
|
|
1776
1794
|
const target = event.target;
|
|
@@ -2124,7 +2142,8 @@ function FlightSearchWidget({
|
|
|
2124
2142
|
console.log("Query String:", queryString);
|
|
2125
2143
|
const base = getNormalizedRedirectionBase();
|
|
2126
2144
|
if (base) {
|
|
2127
|
-
const
|
|
2145
|
+
const listingPath = countryCodeConfig.length > 0 ? `/${countryCodeConfig.toUpperCase()}-${languageCodeConfig ? languageCodeConfig.toUpperCase() : "EN"}/flight/listing` : "/flight/listing";
|
|
2146
|
+
const url = `${base}${listingPath}?${queryString}`;
|
|
2128
2147
|
window.location.href = url;
|
|
2129
2148
|
}
|
|
2130
2149
|
};
|
|
@@ -2156,6 +2175,7 @@ function FlightSearchWidget({
|
|
|
2156
2175
|
const label = isOrigin ? "From" : "To";
|
|
2157
2176
|
const list = isOrigin ? getPredictiveState(segmentIndex).fromAirport : getPredictiveState(segmentIndex).toAirport;
|
|
2158
2177
|
const selectedIndex = isOrigin ? getPredictiveState(segmentIndex).selectedFromIndex : getPredictiveState(segmentIndex).selectedToIndex;
|
|
2178
|
+
const isFirstOrigin = segmentIndex === 0 && isOrigin;
|
|
2159
2179
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `sw-form-field sw-pos-rel${isOrigin ? " br-left" : ""} ${validationErrors[segmentIndex]?.[dropdownType] ? "sw-is-invalid" : ""}`, children: [
|
|
2160
2180
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${dropdownType}-${segmentIndex}`, children: label }),
|
|
2161
2181
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `sw-custom-dropdown ${validationErrors[segmentIndex]?.[dropdownType] ? "sw-has-error" : ""}`, ref: dropdownRef, children: [
|
|
@@ -2186,6 +2206,7 @@ function FlightSearchWidget({
|
|
|
2186
2206
|
{
|
|
2187
2207
|
type: "text",
|
|
2188
2208
|
id: `${dropdownType}-${segmentIndex}`,
|
|
2209
|
+
ref: isFirstOrigin ? firstOriginDesktopInputRef : void 0,
|
|
2189
2210
|
className: `sw-custom-dropdown-trigger MobileHide ${value === placeholder || !value ? "sw-placeholder" : ""}`,
|
|
2190
2211
|
value: value === placeholder ? "" : value ?? "",
|
|
2191
2212
|
placeholder,
|