@planetaexo/design-system 0.22.1 → 0.23.0

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
@@ -2801,8 +2801,15 @@ function AdventureSection({
2801
2801
  ] })
2802
2802
  ] }),
2803
2803
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col divide-y divide-border", children: adventure.travellers.map((t) => {
2804
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
2805
- const canRemoveTraveller = adventure.travellers.length > 1;
2804
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2;
2805
+ const canRemoveTraveller = adventure.travellers.length > 1 || adventure.allowEmptyAdventure === true;
2806
+ const isRemovingLastTraveller = adventure.allowEmptyAdventure === true && adventure.travellers.length === 1;
2807
+ const confirmRemoveLastMessage = (_b2 = (_a2 = labels == null ? void 0 : labels.confirmRemoveLastTraveller) == null ? void 0 : _a2.message) != null ? _b2 : "The adventure will be empty. Continue?";
2808
+ const confirmIfLast = () => {
2809
+ if (!isRemovingLastTraveller) return true;
2810
+ if (typeof window === "undefined") return true;
2811
+ return window.confirm(confirmRemoveLastMessage);
2812
+ };
2806
2813
  const disabledRemoveTitle = canRemoveTraveller ? void 0 : cannotRemoveLastTravellerLabel != null ? cannotRemoveLastTravellerLabel : "Cannot remove last traveller";
2807
2814
  return /* @__PURE__ */ jsxRuntime.jsxs(
2808
2815
  "div",
@@ -2816,7 +2823,7 @@ function AdventureSection({
2816
2823
  " ",
2817
2824
  t.lastName
2818
2825
  ] }),
2819
- t.isChild && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-semibold font-heading rounded-full px-2 py-0.5 bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400 shrink-0", children: (_a2 = labels == null ? void 0 : labels.childBadge) != null ? _a2 : "Child" })
2826
+ t.isChild && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-semibold font-heading rounded-full px-2 py-0.5 bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400 shrink-0", children: (_c2 = labels == null ? void 0 : labels.childBadge) != null ? _c2 : "Child" })
2820
2827
  ] }),
2821
2828
  t.formUrl && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2822
2829
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2828,7 +2835,7 @@ function AdventureSection({
2828
2835
  className: "flex items-center gap-1 text-xs text-primary hover:text-primary/80 transition-colors font-ui",
2829
2836
  children: [
2830
2837
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLinkIcon, { className: "w-3 h-3" }),
2831
- (_b2 = labels == null ? void 0 : labels.openFormLink) != null ? _b2 : "Open"
2838
+ (_d2 = labels == null ? void 0 : labels.openFormLink) != null ? _d2 : "Open"
2832
2839
  ]
2833
2840
  }
2834
2841
  ),
@@ -2838,7 +2845,7 @@ function AdventureSection({
2838
2845
  type: "button",
2839
2846
  onClick: () => handleCopyUrl(t.formUrl),
2840
2847
  className: "flex items-center text-xs text-muted-foreground hover:text-primary transition-colors font-ui",
2841
- "aria-label": (_c2 = labels == null ? void 0 : labels.copyFormUrlAria) != null ? _c2 : "Copy form URL",
2848
+ "aria-label": (_e2 = labels == null ? void 0 : labels.copyFormUrlAria) != null ? _e2 : "Copy form URL",
2842
2849
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CopyIcon, { className: "w-3 h-3" })
2843
2850
  }
2844
2851
  )
@@ -2852,7 +2859,7 @@ function AdventureSection({
2852
2859
  "inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-bold font-heading uppercase tracking-wider shrink-0",
2853
2860
  t.status === "completed" ? "bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400" : "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"
2854
2861
  ),
2855
- children: t.status === "completed" ? (_d2 = labels == null ? void 0 : labels.travellerStatusCompleted) != null ? _d2 : t.status : (_e2 = labels == null ? void 0 : labels.travellerStatusPending) != null ? _e2 : t.status
2862
+ children: t.status === "completed" ? (_f2 = labels == null ? void 0 : labels.travellerStatusCompleted) != null ? _f2 : t.status : (_g2 = labels == null ? void 0 : labels.travellerStatusPending) != null ? _g2 : t.status
2856
2863
  }
2857
2864
  ),
2858
2865
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-0.5 shrink-0", children: [
@@ -2868,7 +2875,7 @@ function AdventureSection({
2868
2875
  }
2869
2876
  },
2870
2877
  className: "flex h-8 w-8 sm:h-7 sm:w-7 items-center justify-center rounded-lg text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors",
2871
- "aria-label": (_g2 = (_f2 = labels == null ? void 0 : labels.editTravellerAria) == null ? void 0 : _f2.call(labels, t.firstName)) != null ? _g2 : `Edit ${t.firstName}`,
2878
+ "aria-label": (_i2 = (_h2 = labels == null ? void 0 : labels.editTravellerAria) == null ? void 0 : _h2.call(labels, t.firstName)) != null ? _i2 : `Edit ${t.firstName}`,
2872
2879
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PencilIcon, { className: "w-3.5 h-3.5" })
2873
2880
  }
2874
2881
  ),
@@ -2878,6 +2885,7 @@ function AdventureSection({
2878
2885
  type: "button",
2879
2886
  onClick: () => {
2880
2887
  if (!canRemoveTraveller) return;
2888
+ if (!confirmIfLast()) return;
2881
2889
  if (onRemoveTraveller) {
2882
2890
  onRemoveTraveller(adventure.id, t.id);
2883
2891
  } else {
@@ -2891,7 +2899,7 @@ function AdventureSection({
2891
2899
  "flex h-8 w-8 sm:h-7 sm:w-7 items-center justify-center rounded-lg text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",
2892
2900
  "disabled:opacity-40 disabled:cursor-not-allowed disabled:pointer-events-none disabled:hover:text-muted-foreground disabled:hover:bg-transparent"
2893
2901
  ),
2894
- "aria-label": (_i2 = (_h2 = labels == null ? void 0 : labels.deleteTravellerAria) == null ? void 0 : _h2.call(labels, t.firstName)) != null ? _i2 : `Delete ${t.firstName}`,
2902
+ "aria-label": (_k2 = (_j2 = labels == null ? void 0 : labels.deleteTravellerAria) == null ? void 0 : _j2.call(labels, t.firstName)) != null ? _k2 : `Delete ${t.firstName}`,
2895
2903
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2Icon, { className: "w-3.5 h-3.5" })
2896
2904
  }
2897
2905
  ),
@@ -2901,6 +2909,7 @@ function AdventureSection({
2901
2909
  type: "button",
2902
2910
  onClick: () => {
2903
2911
  if (!canRemoveTraveller) return;
2912
+ if (!confirmIfLast()) return;
2904
2913
  if (onUnassignFromAdventure) {
2905
2914
  onUnassignFromAdventure(adventure.id, t.id);
2906
2915
  } else if (onRemoveTraveller) {
@@ -2916,7 +2925,7 @@ function AdventureSection({
2916
2925
  "flex h-8 w-8 sm:h-7 sm:w-7 items-center justify-center rounded-lg text-muted-foreground hover:text-amber-500 hover:bg-amber-500/10 transition-colors",
2917
2926
  "disabled:opacity-40 disabled:cursor-not-allowed disabled:pointer-events-none disabled:hover:text-muted-foreground disabled:hover:bg-transparent"
2918
2927
  ),
2919
- "aria-label": (_k2 = (_j2 = labels == null ? void 0 : labels.removeFromAdventureAria) == null ? void 0 : _j2.call(labels, t.firstName)) != null ? _k2 : `Remove ${t.firstName} from adventure`,
2928
+ "aria-label": (_m2 = (_l2 = labels == null ? void 0 : labels.removeFromAdventureAria) == null ? void 0 : _l2.call(labels, t.firstName)) != null ? _m2 : `Remove ${t.firstName} from adventure`,
2920
2929
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.UserMinusIcon, { className: "w-3.5 h-3.5" })
2921
2930
  }
2922
2931
  )
@@ -3482,13 +3491,18 @@ function BookingDetails({
3482
3491
  const closeDeleteModal = React23__namespace.useCallback(() => {
3483
3492
  setDeleteModalState({ open: false, adventureId: null, traveller: null });
3484
3493
  }, []);
3494
+ const submitInFlightRef = React23__namespace.useRef(false);
3485
3495
  const handleAddSubmit = React23__namespace.useCallback(
3486
3496
  async (adventureId, data) => {
3487
3497
  if (!onSubmitAddTraveller) return;
3498
+ if (submitInFlightRef.current) return;
3499
+ submitInFlightRef.current = true;
3488
3500
  try {
3489
3501
  await onSubmitAddTraveller(adventureId, data);
3490
3502
  closeAddModal();
3491
3503
  } catch (e) {
3504
+ } finally {
3505
+ submitInFlightRef.current = false;
3492
3506
  }
3493
3507
  },
3494
3508
  [onSubmitAddTraveller, closeAddModal]
@@ -3496,10 +3510,14 @@ function BookingDetails({
3496
3510
  const handleEditSubmit = React23__namespace.useCallback(
3497
3511
  async (adventureId, travellerId, data) => {
3498
3512
  if (!onSubmitEditTraveller) return;
3513
+ if (submitInFlightRef.current) return;
3514
+ submitInFlightRef.current = true;
3499
3515
  try {
3500
3516
  await onSubmitEditTraveller(adventureId, travellerId, data);
3501
3517
  closeEditModal();
3502
3518
  } catch (e) {
3519
+ } finally {
3520
+ submitInFlightRef.current = false;
3503
3521
  }
3504
3522
  },
3505
3523
  [onSubmitEditTraveller, closeEditModal]
@@ -3507,10 +3525,14 @@ function BookingDetails({
3507
3525
  const handleDeleteConfirm = React23__namespace.useCallback(
3508
3526
  async (adventureId, travellerId) => {
3509
3527
  if (!onConfirmRemoveTraveller) return;
3528
+ if (submitInFlightRef.current) return;
3529
+ submitInFlightRef.current = true;
3510
3530
  try {
3511
3531
  await onConfirmRemoveTraveller(adventureId, travellerId);
3512
3532
  closeDeleteModal();
3513
3533
  } catch (e) {
3534
+ } finally {
3535
+ submitInFlightRef.current = false;
3514
3536
  }
3515
3537
  },
3516
3538
  [onConfirmRemoveTraveller, closeDeleteModal]