@planetaexo/design-system 0.3.0 → 0.3.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
@@ -1069,21 +1069,33 @@ function CountrySearchField({
1069
1069
  ] });
1070
1070
  }
1071
1071
  function AdventureCard({ adventure }) {
1072
- var _a, _b, _c;
1073
- const [checked, setChecked] = React18__namespace.useState(
1074
- new Set((_b = (_a = adventure.optionals) == null ? void 0 : _a.filter((o) => o.defaultChecked).map((o) => o.id)) != null ? _b : [])
1072
+ var _a, _b, _c, _d, _e;
1073
+ const isControlled = (_b = (_a = adventure.optionals) == null ? void 0 : _a.some((o) => o.onCheckedChange !== void 0)) != null ? _b : false;
1074
+ const [checkedInternal, setCheckedInternal] = React18__namespace.useState(
1075
+ new Set((_d = (_c = adventure.optionals) == null ? void 0 : _c.filter((o) => o.defaultChecked).map((o) => o.id)) != null ? _d : [])
1075
1076
  );
1076
- const toggleOptional = (id) => setChecked((prev) => {
1077
- const next = new Set(prev);
1078
- next.has(id) ? next.delete(id) : next.add(id);
1079
- return next;
1080
- });
1077
+ const isChecked = (opt) => {
1078
+ var _a2;
1079
+ return isControlled ? (_a2 = opt.checked) != null ? _a2 : false : checkedInternal.has(opt.id);
1080
+ };
1081
+ const toggleOptional = (opt) => {
1082
+ var _a2;
1083
+ if (isControlled) {
1084
+ (_a2 = opt.onCheckedChange) == null ? void 0 : _a2.call(opt, opt.id, !opt.checked);
1085
+ } else {
1086
+ setCheckedInternal((prev) => {
1087
+ const next = new Set(prev);
1088
+ next.has(opt.id) ? next.delete(opt.id) : next.add(opt.id);
1089
+ return next;
1090
+ });
1091
+ }
1092
+ };
1081
1093
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-2xl border border-border bg-card overflow-hidden", children: [
1082
1094
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aspect-[16/7] overflow-hidden bg-muted", children: /* @__PURE__ */ jsxRuntime.jsx(
1083
1095
  "img",
1084
1096
  {
1085
1097
  src: adventure.image,
1086
- alt: (_c = adventure.imageAlt) != null ? _c : adventure.title,
1098
+ alt: (_e = adventure.imageAlt) != null ? _e : adventure.title,
1087
1099
  className: "w-full h-full object-cover"
1088
1100
  }
1089
1101
  ) }),
@@ -1125,8 +1137,8 @@ function AdventureCard({ adventure }) {
1125
1137
  "input",
1126
1138
  {
1127
1139
  type: "checkbox",
1128
- checked: checked.has(opt.id),
1129
- onChange: () => toggleOptional(opt.id),
1140
+ checked: isChecked(opt),
1141
+ onChange: () => toggleOptional(opt),
1130
1142
  className: "h-4 w-4 shrink-0 rounded border-border accent-primary cursor-pointer"
1131
1143
  }
1132
1144
  ),
@@ -1851,14 +1863,16 @@ function Offer({
1851
1863
  onContinue,
1852
1864
  continueLabel = "Book now",
1853
1865
  externalBookingFlow,
1866
+ checkoutSlot,
1854
1867
  summaryNotesSlot,
1855
1868
  summaryDiscountLine,
1856
1869
  continueDisabled,
1857
1870
  className
1858
1871
  }) {
1859
1872
  const [showBooking, setShowBooking] = React18__namespace.useState(false);
1873
+ const isShowingCheckout = !!checkoutSlot || showBooking;
1860
1874
  const handleBook = () => {
1861
- if (!externalBookingFlow) setShowBooking(true);
1875
+ if (!checkoutSlot && !externalBookingFlow) setShowBooking(true);
1862
1876
  onContinue == null ? void 0 : onContinue();
1863
1877
  };
1864
1878
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full max-w-5xl mx-auto flex flex-col gap-6 pb-20 lg:pb-0", className), children: [
@@ -1874,7 +1888,7 @@ function Offer({
1874
1888
  ] }),
1875
1889
  adventures.map((adventure) => /* @__PURE__ */ jsxRuntime.jsx(AdventureCard, { adventure }, adventure.id))
1876
1890
  ] }),
1877
- !showBooking && /* @__PURE__ */ jsxRuntime.jsx(
1891
+ !isShowingCheckout && /* @__PURE__ */ jsxRuntime.jsx(
1878
1892
  OfferSummarySection,
1879
1893
  {
1880
1894
  adventures,
@@ -1888,7 +1902,7 @@ function Offer({
1888
1902
  continueDisabled
1889
1903
  }
1890
1904
  ),
1891
- showBooking && !externalBookingFlow && /* @__PURE__ */ jsxRuntime.jsx(
1905
+ isShowingCheckout && (checkoutSlot != null ? checkoutSlot : /* @__PURE__ */ jsxRuntime.jsx(
1892
1906
  BookingWizard,
1893
1907
  {
1894
1908
  adventures,
@@ -1896,7 +1910,7 @@ function Offer({
1896
1910
  depositInfo,
1897
1911
  onCancel: () => setShowBooking(false)
1898
1912
  }
1899
- )
1913
+ ))
1900
1914
  ] }),
1901
1915
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "lg:sticky lg:top-8", children: /* @__PURE__ */ jsxRuntime.jsx(
1902
1916
  OfferSidebar,
@@ -1909,7 +1923,7 @@ function Offer({
1909
1923
  }
1910
1924
  ) })
1911
1925
  ] }),
1912
- !showBooking && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed bottom-0 inset-x-0 z-40 border-t border-border bg-background/95 backdrop-blur-sm px-4 py-3 lg:hidden", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-4 max-w-5xl mx-auto", children: [
1926
+ !isShowingCheckout && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed bottom-0 inset-x-0 z-40 border-t border-border bg-background/95 backdrop-blur-sm px-4 py-3 lg:hidden", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-4 max-w-5xl mx-auto", children: [
1913
1927
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
1914
1928
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] uppercase tracking-widest text-muted-foreground font-heading", children: "Total" }),
1915
1929
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xl font-black text-primary font-heading leading-tight", children: total })