@travelswitchhq/flight-search-react 1.2.0 → 1.2.2
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 +37 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +37 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -57,6 +57,11 @@ type FlightSearchWidgetProps = {
|
|
|
57
57
|
* If {@link countryCode} is set and this is omitted, the locale path segment still uses "EN".
|
|
58
58
|
*/
|
|
59
59
|
languageCode?: string;
|
|
60
|
+
/**
|
|
61
|
+
* ISO 4217 currency code for the `curr` query param (e.g. "INR", "AED").
|
|
62
|
+
* Defaults to `"INR"` when omitted.
|
|
63
|
+
*/
|
|
64
|
+
currency?: string;
|
|
60
65
|
};
|
|
61
66
|
ssoUser?: FlightSearchSsoUser;
|
|
62
67
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,11 @@ type FlightSearchWidgetProps = {
|
|
|
57
57
|
* If {@link countryCode} is set and this is omitted, the locale path segment still uses "EN".
|
|
58
58
|
*/
|
|
59
59
|
languageCode?: string;
|
|
60
|
+
/**
|
|
61
|
+
* ISO 4217 currency code for the `curr` query param (e.g. "INR", "AED").
|
|
62
|
+
* Defaults to `"INR"` when omitted.
|
|
63
|
+
*/
|
|
64
|
+
currency?: string;
|
|
60
65
|
};
|
|
61
66
|
ssoUser?: FlightSearchSsoUser;
|
|
62
67
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -735,7 +735,7 @@ padding-inline-start: 25px;
|
|
|
735
735
|
gap: 10px;
|
|
736
736
|
width: fit-content;
|
|
737
737
|
margin-top: 15px;
|
|
738
|
-
color: var(--
|
|
738
|
+
color: var(--secondary-bg-text);
|
|
739
739
|
font-size: 14px;
|
|
740
740
|
}
|
|
741
741
|
.sw-advanced-search-options .p-toggleable-content {
|
|
@@ -847,9 +847,6 @@ padding-inline-start: 25px;
|
|
|
847
847
|
max-width: 100%;
|
|
848
848
|
height: auto;
|
|
849
849
|
}
|
|
850
|
-
.sw-container {
|
|
851
|
-
isolation: isolate;
|
|
852
|
-
}
|
|
853
850
|
.sw-srh-grid {
|
|
854
851
|
display: grid;
|
|
855
852
|
grid-template-columns: minmax(200px, 2fr) minmax(100px, 1fr) minmax(80px, 0.6fr) minmax(60px, 0.4fr);
|
|
@@ -1495,6 +1492,7 @@ function FlightSearchWidget({
|
|
|
1495
1492
|
const airlineSearchApiBaseUrl = urls.airline;
|
|
1496
1493
|
const countryCodeConfig = (config?.countryCode ?? "").trim();
|
|
1497
1494
|
const languageCodeConfig = (config?.languageCode ?? "").trim();
|
|
1495
|
+
const currencyCodeConfig = (config?.currency ?? "INR").trim().toUpperCase();
|
|
1498
1496
|
const langCode = languageCodeConfig || "en";
|
|
1499
1497
|
const [airlineQuery, setAirlineQuery] = useState("");
|
|
1500
1498
|
const [airlineSuggestions, setAirlineSuggestions] = useState([]);
|
|
@@ -1751,12 +1749,6 @@ function FlightSearchWidget({
|
|
|
1751
1749
|
getAirlineListBySearch(value).then(setAirlineSuggestions);
|
|
1752
1750
|
}, DEBOUNCE_MS);
|
|
1753
1751
|
}, [getAirlineListBySearch]);
|
|
1754
|
-
useEffect(() => {
|
|
1755
|
-
if (typeof window === "undefined") return;
|
|
1756
|
-
if (window.matchMedia("(max-width: 768px)").matches) {
|
|
1757
|
-
setIsOriginDropdownOpen(false);
|
|
1758
|
-
}
|
|
1759
|
-
}, []);
|
|
1760
1752
|
useEffect(() => () => {
|
|
1761
1753
|
if (searchDebounceRef.current) clearTimeout(searchDebounceRef.current);
|
|
1762
1754
|
if (airlineSearchDebounceRef.current) clearTimeout(airlineSearchDebounceRef.current);
|
|
@@ -1776,24 +1768,35 @@ function FlightSearchWidget({
|
|
|
1776
1768
|
},
|
|
1777
1769
|
[primaryColor, secondaryColor, primaryLightColor, secondaryBgText]
|
|
1778
1770
|
);
|
|
1771
|
+
const isAnyAirportDropdownOpen = useMemo(() => {
|
|
1772
|
+
if (isOriginDropdownOpen || isDestinationDropdownOpen || isRoomsGuestsMenuOpen) return true;
|
|
1773
|
+
return Object.values(segmentDropdowns).some(
|
|
1774
|
+
(entry) => Boolean(entry?.origin || entry?.destination)
|
|
1775
|
+
);
|
|
1776
|
+
}, [isOriginDropdownOpen, isDestinationDropdownOpen, isRoomsGuestsMenuOpen, segmentDropdowns]);
|
|
1779
1777
|
useEffect(() => {
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1778
|
+
if (typeof document === "undefined" || typeof window === "undefined") return;
|
|
1779
|
+
const mobileQuery = window.matchMedia("(max-width: 1024px)");
|
|
1780
|
+
const syncOverflow = () => {
|
|
1781
|
+
if (!mobileQuery.matches) {
|
|
1782
|
+
document.documentElement.style.overflow = "";
|
|
1783
|
+
return;
|
|
1784
|
+
}
|
|
1785
|
+
document.documentElement.style.overflow = isAnyAirportDropdownOpen ? "hidden" : "auto";
|
|
1788
1786
|
};
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
innerRaf = window.requestAnimationFrame(focusFirstOrigin);
|
|
1792
|
-
});
|
|
1787
|
+
syncOverflow();
|
|
1788
|
+
mobileQuery.addEventListener("change", syncOverflow);
|
|
1793
1789
|
return () => {
|
|
1794
|
-
|
|
1795
|
-
|
|
1790
|
+
mobileQuery.removeEventListener("change", syncOverflow);
|
|
1791
|
+
document.documentElement.style.overflow = "";
|
|
1796
1792
|
};
|
|
1793
|
+
}, [isAnyAirportDropdownOpen]);
|
|
1794
|
+
useEffect(() => {
|
|
1795
|
+
ensureStylesInjected();
|
|
1796
|
+
ensurePrimeIconsLoaded();
|
|
1797
|
+
setIsOriginDropdownOpen(false);
|
|
1798
|
+
setIsDestinationDropdownOpen(false);
|
|
1799
|
+
setSegmentDropdowns({});
|
|
1797
1800
|
}, []);
|
|
1798
1801
|
useEffect(() => {
|
|
1799
1802
|
const handleClickOutside = (event) => {
|
|
@@ -2120,7 +2123,7 @@ function FlightSearchWidget({
|
|
|
2120
2123
|
queryStringObj[`airlines`] = advancedOptions.preferredAirlineList.join(",") || "";
|
|
2121
2124
|
queryStringObj[`ref`] = advancedOptions.isRefundable;
|
|
2122
2125
|
queryStringObj[`lc`] = (langCode ?? "en").toUpperCase();
|
|
2123
|
-
queryStringObj[`curr`] =
|
|
2126
|
+
queryStringObj[`curr`] = currencyCodeConfig;
|
|
2124
2127
|
queryStringObj[`mgcc`] = "AE";
|
|
2125
2128
|
queryStringObj["ipc"] = isFlexiDateOption();
|
|
2126
2129
|
queryStringObj[`umrah`] = isUmrahFareOption();
|
|
@@ -2206,15 +2209,18 @@ function FlightSearchWidget({
|
|
|
2206
2209
|
{
|
|
2207
2210
|
type: "text",
|
|
2208
2211
|
readOnly: true,
|
|
2212
|
+
autoComplete: "off",
|
|
2209
2213
|
id: `${dropdownType}-${segmentIndex}`,
|
|
2210
2214
|
className: `sw-custom-dropdown-trigger MobileShow ${value === placeholder || !value ? "sw-placeholder" : ""}`,
|
|
2211
2215
|
value: value === placeholder ? "" : value ?? "",
|
|
2212
2216
|
placeholder,
|
|
2213
2217
|
onFocus: (e) => {
|
|
2218
|
+
if (isOpen) e.currentTarget.select();
|
|
2219
|
+
},
|
|
2220
|
+
onClick: (e) => {
|
|
2214
2221
|
onOpen();
|
|
2215
2222
|
e.currentTarget.select();
|
|
2216
2223
|
},
|
|
2217
|
-
onClick: (e) => e.currentTarget.select(),
|
|
2218
2224
|
onChange: (e) => {
|
|
2219
2225
|
const val = e.target.value;
|
|
2220
2226
|
handleSegmentFieldChange(segmentIndex, dropdownType, val);
|
|
@@ -2232,11 +2238,14 @@ function FlightSearchWidget({
|
|
|
2232
2238
|
className: `sw-custom-dropdown-trigger MobileHide ${value === placeholder || !value ? "sw-placeholder" : ""}`,
|
|
2233
2239
|
value: value === placeholder ? "" : value ?? "",
|
|
2234
2240
|
placeholder,
|
|
2241
|
+
autoComplete: "off",
|
|
2235
2242
|
onFocus: (e) => {
|
|
2243
|
+
if (isOpen) e.currentTarget.select();
|
|
2244
|
+
},
|
|
2245
|
+
onClick: (e) => {
|
|
2236
2246
|
onOpen();
|
|
2237
2247
|
e.currentTarget.select();
|
|
2238
2248
|
},
|
|
2239
|
-
onClick: (e) => e.currentTarget.select(),
|
|
2240
2249
|
onChange: (e) => {
|
|
2241
2250
|
const val = e.target.value;
|
|
2242
2251
|
handleSegmentFieldChange(segmentIndex, dropdownType, val);
|
|
@@ -2438,7 +2447,7 @@ function FlightSearchWidget({
|
|
|
2438
2447
|
/* @__PURE__ */ jsx("div", { className: "sw-srh-main-head", children: /* @__PURE__ */ jsx("div", { className: "sw-srh-head", children: /* @__PURE__ */ jsx("div", { className: "sw-srh-round-text", children: [
|
|
2439
2448
|
{ value: "round-trip", label: "Round-trip" },
|
|
2440
2449
|
{ value: "one-way", label: "One-way" },
|
|
2441
|
-
{ value: "custom-search", label: "Custom Search" },
|
|
2450
|
+
// { value: "custom-search", label: "Custom Search" },
|
|
2442
2451
|
{ value: "multi-city", label: "Multi-city" }
|
|
2443
2452
|
].map((option) => /* @__PURE__ */ jsxs("label", { className: "sw-tab-checkbox", children: [
|
|
2444
2453
|
/* @__PURE__ */ jsx(
|