@burdenoff/website-sdk 2026.1003.2 → 2026.1003.3

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.js CHANGED
@@ -375,6 +375,17 @@ function useWebSDKConfig() {
375
375
  const client = useWebSDK();
376
376
  return client.getConfig();
377
377
  }
378
+ var RECAPTCHA_WIDGET_HEIGHT = 78;
379
+ function useDeferredRecaptcha(siteKey) {
380
+ const [engaged, setEngaged] = React.useState(false);
381
+ const arm = React.useCallback(() => setEngaged(true), []);
382
+ const enabled = siteKey.length > 0;
383
+ return {
384
+ armed: enabled && engaged,
385
+ arm,
386
+ formProps: enabled && !engaged ? { onFocus: arm, onPointerDown: arm } : {}
387
+ };
388
+ }
378
389
 
379
390
  // src/utils/product-slug.ts
380
391
  var PRODUCT_SLUG_RENAMES = Object.freeze(
@@ -838,12 +849,14 @@ function ContactPage({
838
849
  const displayName = productName ?? product?.name ?? config.productId;
839
850
  const effectiveRecaptchaSiteKey = recaptchaSiteKey ?? product?.recaptchaSiteKey ?? config.recaptchaSiteKey ?? "";
840
851
  const recaptchaRef = React.useRef(null);
852
+ const recaptchaGate = useDeferredRecaptcha(effectiveRecaptchaSiteKey);
841
853
  const [isSubmitting, setIsSubmitting] = React.useState(false);
842
854
  const [submitStatus, setSubmitStatus] = React.useState("idle");
843
855
  const handleSubmit = async (e) => {
844
856
  e.preventDefault();
845
857
  const recaptchaToken = recaptchaRef.current?.getValue() ?? "";
846
858
  if (effectiveRecaptchaSiteKey && !recaptchaToken) {
859
+ recaptchaGate.arm();
847
860
  sonner.toast.error("Please complete the reCAPTCHA verification");
848
861
  return;
849
862
  }
@@ -970,6 +983,7 @@ function ContactPage({
970
983
  {
971
984
  onSubmit: handleSubmit,
972
985
  className: "space-y-4 sm:space-y-6",
986
+ ...recaptchaGate.formProps,
973
987
  children: [
974
988
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid sm:grid-cols-2 gap-4 sm:gap-6", children: [
975
989
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
@@ -1094,13 +1108,20 @@ function ContactPage({
1094
1108
  )
1095
1109
  ] }),
1096
1110
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
1097
- effectiveRecaptchaSiteKey && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center sm:justify-start", children: /* @__PURE__ */ jsxRuntime.jsx(
1098
- ReCAPTCHA4__default.default,
1111
+ effectiveRecaptchaSiteKey && /* @__PURE__ */ jsxRuntime.jsx(
1112
+ "div",
1099
1113
  {
1100
- ref: recaptchaRef,
1101
- sitekey: effectiveRecaptchaSiteKey
1114
+ className: "flex justify-center sm:justify-start",
1115
+ style: { minHeight: RECAPTCHA_WIDGET_HEIGHT },
1116
+ children: recaptchaGate.armed && /* @__PURE__ */ jsxRuntime.jsx(
1117
+ ReCAPTCHA4__default.default,
1118
+ {
1119
+ ref: recaptchaRef,
1120
+ sitekey: effectiveRecaptchaSiteKey
1121
+ }
1122
+ )
1102
1123
  }
1103
- ) }),
1124
+ ),
1104
1125
  /* @__PURE__ */ jsxRuntime.jsx(
1105
1126
  Button,
1106
1127
  {
@@ -2821,6 +2842,7 @@ function NewsletterForm({
2821
2842
  const effectiveProductId = product?.id || config.productId;
2822
2843
  const effectiveRecaptchaSiteKey = recaptchaSiteKey ?? productConfig.recaptchaSiteKey ?? config.recaptchaSiteKey ?? "";
2823
2844
  const recaptchaRef = React.useRef(null);
2845
+ const recaptchaGate = useDeferredRecaptcha(effectiveRecaptchaSiteKey);
2824
2846
  const [email, setEmail] = React.useState("");
2825
2847
  const [isLoading, setIsLoading] = React.useState(false);
2826
2848
  const handleSubmit = async (e) => {
@@ -2831,6 +2853,7 @@ function NewsletterForm({
2831
2853
  }
2832
2854
  const recaptchaToken = recaptchaRef.current?.getValue() ?? "";
2833
2855
  if (effectiveRecaptchaSiteKey && !recaptchaToken) {
2856
+ recaptchaGate.arm();
2834
2857
  sonner.toast.error("Please complete the reCAPTCHA verification");
2835
2858
  return;
2836
2859
  }
@@ -2869,6 +2892,7 @@ function NewsletterForm({
2869
2892
  onSubmit: handleSubmit,
2870
2893
  className: isInline ? "flex flex-col gap-2" : "flex flex-col gap-2",
2871
2894
  style: { overflow: "visible" },
2895
+ ...recaptchaGate.formProps,
2872
2896
  children: [
2873
2897
  /* @__PURE__ */ jsxRuntime.jsxs(
2874
2898
  "div",
@@ -2939,9 +2963,10 @@ function NewsletterForm({
2939
2963
  position: "relative",
2940
2964
  zIndex: 50,
2941
2965
  display: "flex",
2942
- justifyContent: "flex-start"
2966
+ justifyContent: "flex-start",
2967
+ minHeight: RECAPTCHA_WIDGET_HEIGHT
2943
2968
  },
2944
- children: /* @__PURE__ */ jsxRuntime.jsx(
2969
+ children: recaptchaGate.armed && /* @__PURE__ */ jsxRuntime.jsx(
2945
2970
  ReCAPTCHA4__default.default,
2946
2971
  {
2947
2972
  ref: recaptchaRef,
@@ -17997,7 +18022,7 @@ function FacetList({
17997
18022
  className: `w-full text-left text-sm px-2 py-1 rounded flex items-center justify-between gap-2 transition-colors ${selected === f.value ? "bg-primary/10 text-primary font-medium" : "text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,
17998
18023
  children: [
17999
18024
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: f.value }),
18000
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs opacity-60 flex-shrink-0", children: f.count })
18025
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs flex-shrink-0", children: f.count })
18001
18026
  ]
18002
18027
  }
18003
18028
  ) }, f.value)) })
@@ -18180,7 +18205,7 @@ function StoreBrowsePage({
18180
18205
  className: `w-full text-left text-sm px-2 py-1.5 rounded flex items-center justify-between gap-2 transition-colors ${category === f.value ? "bg-primary/10 text-primary font-medium" : "text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,
18181
18206
  children: [
18182
18207
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: cat?.name ?? f.value }),
18183
- f.count > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs opacity-60 flex-shrink-0", children: f.count })
18208
+ f.count > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs flex-shrink-0", children: f.count })
18184
18209
  ]
18185
18210
  },
18186
18211
  f.value