@hook-sdk/template 0.28.10 → 0.29.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
@@ -2615,6 +2615,7 @@ function AppRoot(props) {
2615
2615
  const {
2616
2616
  config: rawConfig,
2617
2617
  children,
2618
+ videos,
2618
2619
  testRouter,
2619
2620
  testInitialEntries,
2620
2621
  Login,
@@ -2684,7 +2685,7 @@ function AppRoot(props) {
2684
2685
  position === "pre-auth" ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(InstallGate, { position: "pre-auth", children: authGated }) : authGated,
2685
2686
  isDevToolsEnabled() && devSkipOnboarding ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DevSkipOnboardingFab, { defaults: devSkipOnboarding.defaults }) : null
2686
2687
  ] });
2687
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(AppConfigProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TemplateConfigProvider, { config: legacyShim, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PersistenceRegistry, { config: config.persistedKeys, children: config.i18n ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2688
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(AppConfigProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TemplateConfigProvider, { config: legacyShim, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PersistenceRegistry, { config: config.persistedKeys, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_sdk9.VideoProvider, { videos: videos ?? {}, children: config.i18n ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2688
2689
  I18nProvider,
2689
2690
  {
2690
2691
  defaultLocale: config.i18n.defaultLocale,
@@ -2692,7 +2693,7 @@ function AppRoot(props) {
2692
2693
  resources: config.i18n.resources,
2693
2694
  children: routedTree
2694
2695
  }
2695
- ) : routedTree }) }) }) }) });
2696
+ ) : routedTree }) }) }) }) }) });
2696
2697
  }
2697
2698
  function AuthGated({
2698
2699
  children,
@@ -3074,9 +3075,26 @@ function useCheckoutForm(hookArgs) {
3074
3075
  const cpfError = touchedCpf || formSubmitAttempted ? validateCpf : null;
3075
3076
  const postalCodeError = touchedPostalCode || formSubmitAttempted ? validatePostalCode : null;
3076
3077
  const addressNumberError = touchedAddressNumber || formSubmitAttempted ? validateAddressNumber : null;
3078
+ const cardExpiryError = (0, import_react18.useMemo)(() => {
3079
+ if (method !== "card") return null;
3080
+ const mm = card.expiryMonth.replace(/\D/g, "");
3081
+ const yy = card.expiryYear.replace(/\D/g, "");
3082
+ if (mm.length < 2 || yy.length < 2) return null;
3083
+ const monthNum = parseInt(mm, 10);
3084
+ if (monthNum < 1 || monthNum > 12) return "M\xEAs inv\xE1lido (use 01-12).";
3085
+ const yearNum = 2e3 + parseInt(yy, 10);
3086
+ const now = /* @__PURE__ */ new Date();
3087
+ const currentMonth = now.getMonth() + 1;
3088
+ const currentYear = now.getFullYear();
3089
+ if (yearNum < currentYear || yearNum === currentYear && monthNum < currentMonth) {
3090
+ return "Cart\xE3o vencido.";
3091
+ }
3092
+ if (yearNum > currentYear + 20) return "Ano muito distante.";
3093
+ return null;
3094
+ }, [method, card.expiryMonth, card.expiryYear]);
3077
3095
  const phoneOk = method === "pix-auto" ? phone === "" || PHONE_RE.test(phone) : PHONE_RE.test(phone);
3078
3096
  const cepGateOk = !hookArgs.collectCep || method !== "card" || postalCode.replace(/\D/g, "").length === 8 && addressNumber.trim().length > 0;
3079
- const canSubmit = name.trim().length >= 2 && EMAIL_RE.test(email) && (emailConfirm === "" || emailConfirm === email) && phoneOk && validateCpf === null && cpf.replace(/\D/g, "").length === 11 && emailStatus !== "exists" && !submitting && cepGateOk && (method !== "card" || card.number.length >= 12 && card.ccv.length >= 3 && card.expiryMonth.length >= 1 && card.expiryYear.length >= 2 && card.holderName.length >= 1);
3097
+ const canSubmit = name.trim().length >= 2 && EMAIL_RE.test(email) && (emailConfirm === "" || emailConfirm === email) && phoneOk && validateCpf === null && cpf.replace(/\D/g, "").length === 11 && emailStatus !== "exists" && !submitting && cepGateOk && (method !== "card" || card.number.length >= 12 && card.ccv.length >= 3 && card.expiryMonth.length >= 1 && card.expiryYear.length >= 2 && card.holderName.length >= 1 && cardExpiryError === null);
3080
3098
  const submit = (0, import_react18.useCallback)(async () => {
3081
3099
  setFormSubmitAttempted(true);
3082
3100
  setError(null);
@@ -3169,6 +3187,7 @@ function useCheckoutForm(hookArgs) {
3169
3187
  cpfError,
3170
3188
  postalCodeError,
3171
3189
  addressNumberError,
3190
+ cardExpiryError,
3172
3191
  markNameTouched: () => setTouchedName(true),
3173
3192
  markEmailTouched: () => setTouchedEmail(true),
3174
3193
  markEmailConfirmTouched: () => setTouchedEmailConfirm(true),
@@ -4136,11 +4155,11 @@ function CheckoutPageDefault() {
4136
4155
  value: form.email,
4137
4156
  onChange: form.setEmail,
4138
4157
  onBlur: form.markEmailTouched,
4139
- error: form.emailError,
4158
+ error: form.emailError ?? (form.emailStatus === "exists" ? "Este email j\xE1 tem conta. Faz login pra continuar." : null),
4140
4159
  valid: form.emailStatus === "available"
4141
4160
  }
4142
4161
  ),
4143
- !form.emailError && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(FieldHint, { children: form.emailStatus === "checking" ? "Verificando\u2026" : form.emailStatus === "available" ? "\u2713 Dispon\xEDvel" : "Voc\xEA vai usar este email para entrar no app" })
4162
+ !form.emailError && form.emailStatus !== "exists" && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(FieldHint, { children: form.emailStatus === "checking" ? "Verificando\u2026" : form.emailStatus === "available" ? "\u2713 Dispon\xEDvel" : "Voc\xEA vai usar este email para entrar no app" })
4144
4163
  ] }),
4145
4164
  /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { children: [
4146
4165
  /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(FieldLabel, { children: "Nome completo" }),
@@ -4291,7 +4310,8 @@ function CheckoutPageDefault() {
4291
4310
  autoComplete: "cc-exp",
4292
4311
  placeholder: "MM/AA",
4293
4312
  value: expiryMmAa,
4294
- onChange: (v) => setExpiryMmAa(formatExpiryMmAa(v))
4313
+ onChange: (v) => setExpiryMmAa(formatExpiryMmAa(v)),
4314
+ error: form.cardExpiryError
4295
4315
  }
4296
4316
  )
4297
4317
  ] }),