@reblu/site-blocks 0.7.0 → 0.8.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.d.cts CHANGED
@@ -645,6 +645,14 @@ interface CheckoutFormProps {
645
645
  contact: CheckoutContactValues;
646
646
  onContactChange: (values: CheckoutContactValues) => void;
647
647
  contactErrors?: CheckoutContactErrors;
648
+ /** Country asserted by the SITE for national phone input; omit rather than guessing. */
649
+ phoneRegion?: string;
650
+ /** Optional raw checkout API error body; only INVALID_INPUT/customerPhone marks the phone field. */
651
+ checkoutError?: {
652
+ code?: unknown;
653
+ error?: unknown;
654
+ details?: unknown;
655
+ } | null;
648
656
  discountCode: string;
649
657
  onDiscountCodeChange: (value: string) => void;
650
658
  onApplyDiscount: () => void;
@@ -670,7 +678,7 @@ interface CheckoutFormProps {
670
678
  locale?: string;
671
679
  className?: string;
672
680
  }
673
- declare function CheckoutForm({ contact, onContactChange, contactErrors, discountCode, onDiscountCodeChange, onApplyDiscount, onRemoveDiscount, appliedDiscount, discountApplying, discountError, loginPrompt, children, submitting, submitDisabled, onSubmit, labels, currencyCode, locale, className, }: CheckoutFormProps): react_jsx_runtime.JSX.Element;
681
+ declare function CheckoutForm({ contact, onContactChange, contactErrors, phoneRegion, checkoutError, discountCode, onDiscountCodeChange, onApplyDiscount, onRemoveDiscount, appliedDiscount, discountApplying, discountError, loginPrompt, children, submitting, submitDisabled, onSubmit, labels, currencyCode, locale, className, }: CheckoutFormProps): react_jsx_runtime.JSX.Element;
674
682
 
675
683
  /**
676
684
  * `OrderConfirmation` — presentational order-confirmation view (REB-829,
package/dist/index.d.ts CHANGED
@@ -645,6 +645,14 @@ interface CheckoutFormProps {
645
645
  contact: CheckoutContactValues;
646
646
  onContactChange: (values: CheckoutContactValues) => void;
647
647
  contactErrors?: CheckoutContactErrors;
648
+ /** Country asserted by the SITE for national phone input; omit rather than guessing. */
649
+ phoneRegion?: string;
650
+ /** Optional raw checkout API error body; only INVALID_INPUT/customerPhone marks the phone field. */
651
+ checkoutError?: {
652
+ code?: unknown;
653
+ error?: unknown;
654
+ details?: unknown;
655
+ } | null;
648
656
  discountCode: string;
649
657
  onDiscountCodeChange: (value: string) => void;
650
658
  onApplyDiscount: () => void;
@@ -670,7 +678,7 @@ interface CheckoutFormProps {
670
678
  locale?: string;
671
679
  className?: string;
672
680
  }
673
- declare function CheckoutForm({ contact, onContactChange, contactErrors, discountCode, onDiscountCodeChange, onApplyDiscount, onRemoveDiscount, appliedDiscount, discountApplying, discountError, loginPrompt, children, submitting, submitDisabled, onSubmit, labels, currencyCode, locale, className, }: CheckoutFormProps): react_jsx_runtime.JSX.Element;
681
+ declare function CheckoutForm({ contact, onContactChange, contactErrors, phoneRegion, checkoutError, discountCode, onDiscountCodeChange, onApplyDiscount, onRemoveDiscount, appliedDiscount, discountApplying, discountError, loginPrompt, children, submitting, submitDisabled, onSubmit, labels, currencyCode, locale, className, }: CheckoutFormProps): react_jsx_runtime.JSX.Element;
674
682
 
675
683
  /**
676
684
  * `OrderConfirmation` — presentational order-confirmation view (REB-829,
package/dist/index.js CHANGED
@@ -13948,6 +13948,7 @@ function CheckoutLoginPrompt({
13948
13948
 
13949
13949
  // src/components/checkout-form.tsx
13950
13950
  import { cn as cn12 } from "@reblu/site-ui/utils";
13951
+ import { PhoneInput } from "@reblu/site-ui/phone-input";
13951
13952
  import { Fragment as Fragment4, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
13952
13953
  var DEFAULT_LABELS6 = {
13953
13954
  contactTitle: "Datos de contacto",
@@ -13969,6 +13970,8 @@ function CheckoutForm({
13969
13970
  contact,
13970
13971
  onContactChange,
13971
13972
  contactErrors,
13973
+ phoneRegion,
13974
+ checkoutError,
13972
13975
  discountCode,
13973
13976
  onDiscountCodeChange,
13974
13977
  onApplyDiscount,
@@ -13987,6 +13990,10 @@ function CheckoutForm({
13987
13990
  className
13988
13991
  }) {
13989
13992
  const t = { ...DEFAULT_LABELS6, ...labels };
13993
+ const details = checkoutError?.details;
13994
+ const rejectedPhone = checkoutError?.code === "INVALID_INPUT" && typeof details === "object" && details !== null && !Array.isArray(details) && "field" in details && details.field === "customerPhone" && typeof checkoutError.error === "string" && checkoutError.error.trim().length > 0;
13995
+ const phoneError = contactErrors?.phone ?? (rejectedPhone ? checkoutError.error : void 0);
13996
+ const generalError = checkoutError && !rejectedPhone ? getShopErrorMessage(typeof checkoutError.code === "string" ? checkoutError.code : void 0) : null;
13990
13997
  function patchContact(patch3) {
13991
13998
  onContactChange({ ...contact, ...patch3 });
13992
13999
  }
@@ -14047,27 +14054,21 @@ function CheckoutForm({
14047
14054
  ),
14048
14055
  contactErrors?.email && /* @__PURE__ */ jsx12("p", { className: "text-xs text-destructive", children: contactErrors.email })
14049
14056
  ] }),
14050
- /* @__PURE__ */ jsxs11("div", { className: "space-y-1", children: [
14051
- /* @__PURE__ */ jsx12("label", { htmlFor: "checkout-form-phone", className: "text-sm font-medium", children: t.phoneLabel }),
14052
- /* @__PURE__ */ jsx12(
14053
- "input",
14054
- {
14055
- id: "checkout-form-phone",
14056
- type: "tel",
14057
- autoComplete: "tel",
14058
- value: contact.phone ?? "",
14059
- onChange: (e) => patchContact({ phone: e.target.value }),
14060
- className: cn12(
14061
- "w-full rounded-lg border bg-background px-3 py-2 text-sm transition focus:outline-none focus:ring-2 focus:ring-primary/20",
14062
- contactErrors?.phone ? "border-destructive" : "border-border focus:border-primary"
14063
- )
14064
- }
14065
- ),
14066
- contactErrors?.phone && /* @__PURE__ */ jsx12("p", { className: "text-xs text-destructive", children: contactErrors.phone })
14067
- ] })
14057
+ /* @__PURE__ */ jsx12("div", { className: "space-y-1", children: /* @__PURE__ */ jsx12(
14058
+ PhoneInput,
14059
+ {
14060
+ id: "checkout-form-phone",
14061
+ label: t.phoneLabel,
14062
+ region: phoneRegion,
14063
+ value: contact.phone ?? "",
14064
+ onChange: (phone) => patchContact({ phone }),
14065
+ error: phoneError
14066
+ }
14067
+ ) })
14068
14068
  ] })
14069
14069
  ] }),
14070
14070
  children2,
14071
+ generalError ? /* @__PURE__ */ jsx12("p", { role: "alert", className: "text-sm text-destructive", children: generalError }) : null,
14071
14072
  /* @__PURE__ */ jsxs11("section", { className: "space-y-3", children: [
14072
14073
  /* @__PURE__ */ jsx12("h2", { className: "border-b border-border pb-2 text-lg font-semibold", children: t.discountTitle }),
14073
14074
  appliedDiscount ? /* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between rounded-lg border border-green-200 bg-green-50 px-4 py-3 dark:border-green-800 dark:bg-green-900/20", children: [