@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 CHANGED
@@ -761,7 +761,7 @@ padding-inline-start: 25px;
761
761
  gap: 10px;
762
762
  width: fit-content;
763
763
  margin-top: 15px;
764
- color: var(--sw-body-text);
764
+ color: var(--secondary-bg-text);
765
765
  font-size: 14px;
766
766
  }
767
767
  .sw-advanced-search-options .p-toggleable-content {
@@ -873,9 +873,6 @@ padding-inline-start: 25px;
873
873
  max-width: 100%;
874
874
  height: auto;
875
875
  }
876
- .sw-container {
877
- isolation: isolate;
878
- }
879
876
  .sw-srh-grid {
880
877
  display: grid;
881
878
  grid-template-columns: minmax(200px, 2fr) minmax(100px, 1fr) minmax(80px, 0.6fr) minmax(60px, 0.4fr);
@@ -1521,6 +1518,7 @@ function FlightSearchWidget({
1521
1518
  const airlineSearchApiBaseUrl = urls.airline;
1522
1519
  const countryCodeConfig = (config?.countryCode ?? "").trim();
1523
1520
  const languageCodeConfig = (config?.languageCode ?? "").trim();
1521
+ const currencyCodeConfig = (config?.currency ?? "INR").trim().toUpperCase();
1524
1522
  const langCode = languageCodeConfig || "en";
1525
1523
  const [airlineQuery, setAirlineQuery] = (0, import_react.useState)("");
1526
1524
  const [airlineSuggestions, setAirlineSuggestions] = (0, import_react.useState)([]);
@@ -1777,12 +1775,6 @@ function FlightSearchWidget({
1777
1775
  getAirlineListBySearch(value).then(setAirlineSuggestions);
1778
1776
  }, DEBOUNCE_MS);
1779
1777
  }, [getAirlineListBySearch]);
1780
- (0, import_react.useEffect)(() => {
1781
- if (typeof window === "undefined") return;
1782
- if (window.matchMedia("(max-width: 768px)").matches) {
1783
- setIsOriginDropdownOpen(false);
1784
- }
1785
- }, []);
1786
1778
  (0, import_react.useEffect)(() => () => {
1787
1779
  if (searchDebounceRef.current) clearTimeout(searchDebounceRef.current);
1788
1780
  if (airlineSearchDebounceRef.current) clearTimeout(airlineSearchDebounceRef.current);
@@ -1802,24 +1794,35 @@ function FlightSearchWidget({
1802
1794
  },
1803
1795
  [primaryColor, secondaryColor, primaryLightColor, secondaryBgText]
1804
1796
  );
1797
+ const isAnyAirportDropdownOpen = (0, import_react.useMemo)(() => {
1798
+ if (isOriginDropdownOpen || isDestinationDropdownOpen || isRoomsGuestsMenuOpen) return true;
1799
+ return Object.values(segmentDropdowns).some(
1800
+ (entry) => Boolean(entry?.origin || entry?.destination)
1801
+ );
1802
+ }, [isOriginDropdownOpen, isDestinationDropdownOpen, isRoomsGuestsMenuOpen, segmentDropdowns]);
1805
1803
  (0, import_react.useEffect)(() => {
1806
- ensureStylesInjected();
1807
- ensurePrimeIconsLoaded();
1808
- }, []);
1809
- (0, import_react.useEffect)(() => {
1810
- if (typeof window === "undefined") return;
1811
- const focusFirstOrigin = () => {
1812
- const desktop = firstOriginDesktopInputRef.current;
1813
- desktop?.focus({ preventScroll: true });
1804
+ if (typeof document === "undefined" || typeof window === "undefined") return;
1805
+ const mobileQuery = window.matchMedia("(max-width: 1024px)");
1806
+ const syncOverflow = () => {
1807
+ if (!mobileQuery.matches) {
1808
+ document.documentElement.style.overflow = "";
1809
+ return;
1810
+ }
1811
+ document.documentElement.style.overflow = isAnyAirportDropdownOpen ? "hidden" : "auto";
1814
1812
  };
1815
- let innerRaf = 0;
1816
- const outerRaf = window.requestAnimationFrame(() => {
1817
- innerRaf = window.requestAnimationFrame(focusFirstOrigin);
1818
- });
1813
+ syncOverflow();
1814
+ mobileQuery.addEventListener("change", syncOverflow);
1819
1815
  return () => {
1820
- window.cancelAnimationFrame(outerRaf);
1821
- if (innerRaf) window.cancelAnimationFrame(innerRaf);
1816
+ mobileQuery.removeEventListener("change", syncOverflow);
1817
+ document.documentElement.style.overflow = "";
1822
1818
  };
1819
+ }, [isAnyAirportDropdownOpen]);
1820
+ (0, import_react.useEffect)(() => {
1821
+ ensureStylesInjected();
1822
+ ensurePrimeIconsLoaded();
1823
+ setIsOriginDropdownOpen(false);
1824
+ setIsDestinationDropdownOpen(false);
1825
+ setSegmentDropdowns({});
1823
1826
  }, []);
1824
1827
  (0, import_react.useEffect)(() => {
1825
1828
  const handleClickOutside = (event) => {
@@ -2146,7 +2149,7 @@ function FlightSearchWidget({
2146
2149
  queryStringObj[`airlines`] = advancedOptions.preferredAirlineList.join(",") || "";
2147
2150
  queryStringObj[`ref`] = advancedOptions.isRefundable;
2148
2151
  queryStringObj[`lc`] = (langCode ?? "en").toUpperCase();
2149
- queryStringObj[`curr`] = "AED";
2152
+ queryStringObj[`curr`] = currencyCodeConfig;
2150
2153
  queryStringObj[`mgcc`] = "AE";
2151
2154
  queryStringObj["ipc"] = isFlexiDateOption();
2152
2155
  queryStringObj[`umrah`] = isUmrahFareOption();
@@ -2232,15 +2235,18 @@ function FlightSearchWidget({
2232
2235
  {
2233
2236
  type: "text",
2234
2237
  readOnly: true,
2238
+ autoComplete: "off",
2235
2239
  id: `${dropdownType}-${segmentIndex}`,
2236
2240
  className: `sw-custom-dropdown-trigger MobileShow ${value === placeholder || !value ? "sw-placeholder" : ""}`,
2237
2241
  value: value === placeholder ? "" : value ?? "",
2238
2242
  placeholder,
2239
2243
  onFocus: (e) => {
2244
+ if (isOpen) e.currentTarget.select();
2245
+ },
2246
+ onClick: (e) => {
2240
2247
  onOpen();
2241
2248
  e.currentTarget.select();
2242
2249
  },
2243
- onClick: (e) => e.currentTarget.select(),
2244
2250
  onChange: (e) => {
2245
2251
  const val = e.target.value;
2246
2252
  handleSegmentFieldChange(segmentIndex, dropdownType, val);
@@ -2258,11 +2264,14 @@ function FlightSearchWidget({
2258
2264
  className: `sw-custom-dropdown-trigger MobileHide ${value === placeholder || !value ? "sw-placeholder" : ""}`,
2259
2265
  value: value === placeholder ? "" : value ?? "",
2260
2266
  placeholder,
2267
+ autoComplete: "off",
2261
2268
  onFocus: (e) => {
2269
+ if (isOpen) e.currentTarget.select();
2270
+ },
2271
+ onClick: (e) => {
2262
2272
  onOpen();
2263
2273
  e.currentTarget.select();
2264
2274
  },
2265
- onClick: (e) => e.currentTarget.select(),
2266
2275
  onChange: (e) => {
2267
2276
  const val = e.target.value;
2268
2277
  handleSegmentFieldChange(segmentIndex, dropdownType, val);
@@ -2464,7 +2473,7 @@ function FlightSearchWidget({
2464
2473
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "sw-srh-main-head", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "sw-srh-head", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "sw-srh-round-text", children: [
2465
2474
  { value: "round-trip", label: "Round-trip" },
2466
2475
  { value: "one-way", label: "One-way" },
2467
- { value: "custom-search", label: "Custom Search" },
2476
+ // { value: "custom-search", label: "Custom Search" },
2468
2477
  { value: "multi-city", label: "Multi-city" }
2469
2478
  ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "sw-tab-checkbox", children: [
2470
2479
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(