@travelswitchhq/flight-search-react 1.0.9 → 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 +62 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +62 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -37,7 +37,6 @@ var flightSearchWidgetStyles = `
|
|
|
37
37
|
.sw-container {
|
|
38
38
|
--sw-font-family: Montserrat, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
39
39
|
--sw-en-font-family: Arial, sans-serif;
|
|
40
|
-
--sw-secondary-bg-text: #ffffff;
|
|
41
40
|
--sw-label-color: #66797F;
|
|
42
41
|
--sw-body-text: #0B1215;
|
|
43
42
|
--sw-btn-radius: 8px;
|
|
@@ -762,7 +761,7 @@ padding-inline-start: 25px;
|
|
|
762
761
|
gap: 10px;
|
|
763
762
|
cursor: pointer;
|
|
764
763
|
user-select: none;
|
|
765
|
-
color: var(--
|
|
764
|
+
color: var(--secondary-bg-text);
|
|
766
765
|
font-size: 14px;
|
|
767
766
|
}
|
|
768
767
|
.sw-material-checkbox input {
|
|
@@ -815,10 +814,13 @@ padding-inline-start: 25px;
|
|
|
815
814
|
background-color: var(--primary-light);
|
|
816
815
|
color: var(--primary);
|
|
817
816
|
}
|
|
817
|
+
.sw-card-box .sw-srh-class .sw-tab-content {
|
|
818
|
+
border: 1px solid var(--sw-form-border);
|
|
819
|
+
}
|
|
818
820
|
.sw-card-box .sw-tab-content {
|
|
819
821
|
height: 40px;
|
|
820
822
|
padding: 6px 15px;
|
|
821
|
-
border: 1px solid var(--
|
|
823
|
+
border: 1px solid var(--secondary-bg-text);
|
|
822
824
|
border-radius: var(--sw-radius);
|
|
823
825
|
align-content: center;
|
|
824
826
|
}
|
|
@@ -888,11 +890,11 @@ padding-inline-start: 25px;
|
|
|
888
890
|
height: 40px;
|
|
889
891
|
}
|
|
890
892
|
.sw-srh-round-text .sw-tab-content{
|
|
891
|
-
color: var(--
|
|
893
|
+
color: var(--secondary-bg-text);
|
|
892
894
|
}
|
|
893
895
|
.sw-advanced-search-options .p-accordion-header-text,
|
|
894
896
|
.sw-card-box .p-accordion-toggle-icon{
|
|
895
|
-
color: var(--
|
|
897
|
+
color: var(--secondary-bg-text);
|
|
896
898
|
}
|
|
897
899
|
.sw-remove-segment{
|
|
898
900
|
fill: var(--primary);
|
|
@@ -971,10 +973,11 @@ padding-inline-start: 25px;
|
|
|
971
973
|
}
|
|
972
974
|
.p-autocomplete-multiple-container {
|
|
973
975
|
width: 100%;
|
|
976
|
+
background-color: var(--sw-white);
|
|
974
977
|
min-width: 270px;
|
|
975
978
|
padding: 10px;
|
|
976
979
|
padding-inline-end: 2rem;
|
|
977
|
-
border: 1px solid var(--
|
|
980
|
+
border: 1px solid var(--secondary-bg-text);
|
|
978
981
|
border-radius: var(--sw-radius);
|
|
979
982
|
gap: 0.5rem;
|
|
980
983
|
font-size: 14px;
|
|
@@ -1110,6 +1113,9 @@ padding-inline-start: 25px;
|
|
|
1110
1113
|
font-size: 14px;
|
|
1111
1114
|
line-height: 1;
|
|
1112
1115
|
}
|
|
1116
|
+
.sw-container .sw-is-invalid{
|
|
1117
|
+
border: 1px solid var(--sw-error);
|
|
1118
|
+
}
|
|
1113
1119
|
.sw-checkbox-wrap .sw-star-checkbox {
|
|
1114
1120
|
display: flex;
|
|
1115
1121
|
align-items: center;
|
|
@@ -1180,6 +1186,7 @@ padding-inline-start: 25px;
|
|
|
1180
1186
|
display: none;
|
|
1181
1187
|
}
|
|
1182
1188
|
}
|
|
1189
|
+
|
|
1183
1190
|
.sw-container .sw-form-field {
|
|
1184
1191
|
border-radius: var(--sw-radius);
|
|
1185
1192
|
}
|
|
@@ -1249,6 +1256,7 @@ padding-inline-start: 25px;
|
|
|
1249
1256
|
width: 100%;
|
|
1250
1257
|
max-height: 100vh;
|
|
1251
1258
|
overflow: auto;
|
|
1259
|
+
display: block !important;
|
|
1252
1260
|
-webkit-overflow-scrolling: touch;
|
|
1253
1261
|
scroll-behavior: smooth;
|
|
1254
1262
|
padding: 0 !important;
|
|
@@ -1471,8 +1479,9 @@ function FlightSearchWidget({
|
|
|
1471
1479
|
}) {
|
|
1472
1480
|
const theme = config?.theme;
|
|
1473
1481
|
const primaryColor = theme?.primary ?? "#2c0a82";
|
|
1474
|
-
const secondaryColor = theme?.secondary ?? "#2c0a82";
|
|
1475
1482
|
const primaryLightColor = theme?.primaryLight ?? "#f3e2ff";
|
|
1483
|
+
const secondaryColor = theme?.secondary ?? "#2c0a82";
|
|
1484
|
+
const secondaryBgText = theme?.secondaryBgText ?? "#ffffff";
|
|
1476
1485
|
const fontName = config?.fontName;
|
|
1477
1486
|
const redirectionDomain = config?.redirectionDomain;
|
|
1478
1487
|
const env = config?.env ?? "dev";
|
|
@@ -1641,6 +1650,23 @@ function FlightSearchWidget({
|
|
|
1641
1650
|
[segmentIndex]: { ...prev[segmentIndex] ?? {}, [dropdownType]: false }
|
|
1642
1651
|
}));
|
|
1643
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
|
+
});
|
|
1644
1670
|
}, [closeAirportDropdown, tripType]);
|
|
1645
1671
|
const updateSelectedIndex = (0, import_react.useCallback)((segmentIndex, dropdownType, newIndex) => {
|
|
1646
1672
|
setPredictiveSearchList((prev) => {
|
|
@@ -1723,15 +1749,16 @@ function FlightSearchWidget({
|
|
|
1723
1749
|
() => {
|
|
1724
1750
|
const style = {
|
|
1725
1751
|
["--primary"]: primaryColor,
|
|
1752
|
+
["--primary-light"]: primaryLightColor,
|
|
1726
1753
|
["--secondary"]: secondaryColor,
|
|
1727
|
-
["--
|
|
1754
|
+
["--secondary-bg-text"]: secondaryBgText
|
|
1728
1755
|
};
|
|
1729
1756
|
if (fontName) {
|
|
1730
1757
|
style["--font-family"] = fontName;
|
|
1731
1758
|
}
|
|
1732
1759
|
return style;
|
|
1733
1760
|
},
|
|
1734
|
-
[primaryColor, secondaryColor, primaryLightColor]
|
|
1761
|
+
[primaryColor, secondaryColor, primaryLightColor, secondaryBgText]
|
|
1735
1762
|
);
|
|
1736
1763
|
(0, import_react.useEffect)(() => {
|
|
1737
1764
|
ensureStylesInjected();
|
|
@@ -1873,19 +1900,6 @@ function FlightSearchWidget({
|
|
|
1873
1900
|
}
|
|
1874
1901
|
return updated;
|
|
1875
1902
|
});
|
|
1876
|
-
if (field === "origin" || field === "destination") {
|
|
1877
|
-
setSegmentDropdowns((prev) => ({
|
|
1878
|
-
...prev,
|
|
1879
|
-
[index]: { ...prev[index], [field]: false }
|
|
1880
|
-
}));
|
|
1881
|
-
const placeholder = field === "origin" ? "Origin" : "Destination";
|
|
1882
|
-
if (isValidLocationValue(value, placeholder)) {
|
|
1883
|
-
setValidationErrors((prev) => ({
|
|
1884
|
-
...prev,
|
|
1885
|
-
[index]: { ...prev[index] ?? {}, [field]: false }
|
|
1886
|
-
}));
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
1903
|
};
|
|
1890
1904
|
const handleTravellerChange = (field, value) => {
|
|
1891
1905
|
setSegments((prev) => {
|
|
@@ -1896,13 +1910,25 @@ function FlightSearchWidget({
|
|
|
1896
1910
|
});
|
|
1897
1911
|
};
|
|
1898
1912
|
const toggleSegmentDropdown = (index, field) => {
|
|
1899
|
-
setSegmentDropdowns((prev) =>
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
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
|
+
};
|
|
1904
1923
|
}
|
|
1905
|
-
|
|
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
|
+
});
|
|
1906
1932
|
};
|
|
1907
1933
|
const swapSegmentLocations = (index) => {
|
|
1908
1934
|
setSegments((prev) => {
|
|
@@ -2155,7 +2181,7 @@ function FlightSearchWidget({
|
|
|
2155
2181
|
] }) }),
|
|
2156
2182
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: isOrigin ? "Origin" : "Destination" })
|
|
2157
2183
|
] }),
|
|
2158
|
-
/* @__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) => {
|
|
2159
2185
|
const val = e.target.value;
|
|
2160
2186
|
handleSegmentFieldChange(segmentIndex, dropdownType, val);
|
|
2161
2187
|
triggerSearchAirport(segmentIndex, dropdownType, val);
|
|
@@ -2217,6 +2243,7 @@ function FlightSearchWidget({
|
|
|
2217
2243
|
numberOfMonths: 2,
|
|
2218
2244
|
id: `departure-${index}`,
|
|
2219
2245
|
appendTo: "self",
|
|
2246
|
+
readOnlyInput: true,
|
|
2220
2247
|
value: segment.departureDate ?? null,
|
|
2221
2248
|
onChange: (e) => {
|
|
2222
2249
|
const raw = e.value;
|
|
@@ -2239,6 +2266,10 @@ function FlightSearchWidget({
|
|
|
2239
2266
|
numberOfMonths: 10,
|
|
2240
2267
|
id: `departure-${index}`,
|
|
2241
2268
|
appendTo: "self",
|
|
2269
|
+
ref: (el) => {
|
|
2270
|
+
segmentCalendarRefs.current[index] = el;
|
|
2271
|
+
},
|
|
2272
|
+
readOnlyInput: true,
|
|
2242
2273
|
value: segment.departureDate ?? null,
|
|
2243
2274
|
onChange: (e) => {
|
|
2244
2275
|
const raw = e.value;
|
|
@@ -2256,7 +2287,7 @@ function FlightSearchWidget({
|
|
|
2256
2287
|
headerTemplate: () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mobileHead MobileShow", children: [
|
|
2257
2288
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { type: "button", onClick: (e) => {
|
|
2258
2289
|
e.stopPropagation();
|
|
2259
|
-
|
|
2290
|
+
segmentCalendarRefs.current[index]?.hide?.();
|
|
2260
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: [
|
|
2261
2292
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M19 5L5 19", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
2262
2293
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 5L19 19", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
@@ -2270,7 +2301,7 @@ function FlightSearchWidget({
|
|
|
2270
2301
|
className: "sw-confirm-btn",
|
|
2271
2302
|
onClick: (e) => {
|
|
2272
2303
|
e.stopPropagation();
|
|
2273
|
-
|
|
2304
|
+
segmentCalendarRefs.current[index]?.hide?.();
|
|
2274
2305
|
},
|
|
2275
2306
|
children: "Confirm"
|
|
2276
2307
|
}
|