@hook-sdk/template 0.28.0 → 0.28.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.d.cts CHANGED
@@ -175,7 +175,7 @@ interface SkipDefaults {
175
175
  declare function skipOnboarding(hook: HookContextValue, defaults: SkipDefaults, appSlug: string): Promise<void>;
176
176
  declare function DevSkipOnboardingFab({ defaults }: {
177
177
  defaults: SkipDefaults;
178
- }): react_jsx_runtime.JSX.Element;
178
+ }): react_jsx_runtime.JSX.Element | null;
179
179
 
180
180
  declare function PaymentReturnHandler({ children }: {
181
181
  children: ReactNode;
package/dist/index.d.ts CHANGED
@@ -175,7 +175,7 @@ interface SkipDefaults {
175
175
  declare function skipOnboarding(hook: HookContextValue, defaults: SkipDefaults, appSlug: string): Promise<void>;
176
176
  declare function DevSkipOnboardingFab({ defaults }: {
177
177
  defaults: SkipDefaults;
178
- }): react_jsx_runtime.JSX.Element;
178
+ }): react_jsx_runtime.JSX.Element | null;
179
179
 
180
180
  declare function PaymentReturnHandler({ children }: {
181
181
  children: ReactNode;
package/dist/index.js CHANGED
@@ -2108,7 +2108,7 @@ function isDevToolsEnabled() {
2108
2108
 
2109
2109
  // src/dev/DevSkipOnboardingFab.tsx
2110
2110
  import { useCallback as useCallback3, useRef as useRef4, useState as useState5 } from "react";
2111
- import { useHook as useHook5 } from "@hook-sdk/sdk";
2111
+ import { useHook as useHook5, usePersistedState as usePersistedState2 } from "@hook-sdk/sdk";
2112
2112
  import { jsx as jsx20 } from "react/jsx-runtime";
2113
2113
  var STORAGE_KEY = "hook_dev_skip_email";
2114
2114
  var TEST_EMAIL_DOMAIN = "@hook.test";
@@ -2181,6 +2181,13 @@ function DevSkipOnboardingFab({ defaults }) {
2181
2181
  const [state, setState] = useState5("idle");
2182
2182
  const [errorMsg, setErrorMsg] = useState5(null);
2183
2183
  const timerRef = useRef4(null);
2184
+ const isAuthed = hook.authStatus === "authenticated";
2185
+ const [onboarding] = usePersistedState2(
2186
+ "onboarding_data",
2187
+ null,
2188
+ { enabled: isAuthed }
2189
+ );
2190
+ const onboardingCompleted = isAuthed && onboarding?.onboarding_completed === true;
2184
2191
  const clearTimer = useCallback3(() => {
2185
2192
  if (timerRef.current) {
2186
2193
  clearTimeout(timerRef.current);
@@ -2211,6 +2218,7 @@ function DevSkipOnboardingFab({ defaults }) {
2211
2218
  if (state === "error") return `failed \u2014 tap to retry`;
2212
2219
  return hook.authStatus === "authenticated" ? "\u26A1 skip onboarding" : "\u26A1 skip + signup";
2213
2220
  })();
2221
+ if (onboardingCompleted) return null;
2214
2222
  const style = {
2215
2223
  ...STYLES.base,
2216
2224
  ...state === "confirm" || state === "error" ? STYLES.confirm : {},
@@ -2684,12 +2692,12 @@ function PushPrompt2({ texts, onSubscribed, onDeclined, onInstallRequested, clas
2684
2692
  }
2685
2693
 
2686
2694
  // src/components/LanguageSwitcher.tsx
2687
- import { usePersistedState as usePersistedState2 } from "@hook-sdk/sdk";
2695
+ import { usePersistedState as usePersistedState3 } from "@hook-sdk/sdk";
2688
2696
  import { jsx as jsx24, jsxs as jsxs16 } from "react/jsx-runtime";
2689
2697
  function LanguageSwitcher({ id, className, label = "Language" }) {
2690
2698
  const config = useAppConfig();
2691
2699
  const i18nConfig = config.i18n;
2692
- const [userLocale, setUserLocale] = usePersistedState2(
2700
+ const [userLocale, setUserLocale] = usePersistedState3(
2693
2701
  "user-locale",
2694
2702
  i18nConfig?.defaultLocale ?? "en-US"
2695
2703
  );
@@ -2851,7 +2859,8 @@ function useCheckoutForm(args) {
2851
2859
  const emailConfirmError = touchedEmailConfirm || formSubmitAttempted ? validateEmailConfirm : null;
2852
2860
  const phoneError = touchedPhone || formSubmitAttempted ? validatePhone : null;
2853
2861
  const cpfError = touchedCpf || formSubmitAttempted ? validateCpf : null;
2854
- const canSubmit = name.trim().length >= 2 && EMAIL_RE.test(email) && (emailConfirm === "" || emailConfirm === email) && (phone === "" || PHONE_RE.test(phone)) && validateCpf === null && cpf.replace(/\D/g, "").length === 11 && emailStatus !== "exists" && !submitting && (method !== "card" || card.number.length >= 12 && card.ccv.length >= 3 && card.expiryMonth.length >= 1 && card.expiryYear.length >= 2 && card.holderName.length >= 1);
2862
+ const phoneOk = method === "pix-auto" ? phone === "" || PHONE_RE.test(phone) : PHONE_RE.test(phone);
2863
+ 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 && (method !== "card" || card.number.length >= 12 && card.ccv.length >= 3 && card.expiryMonth.length >= 1 && card.expiryYear.length >= 2 && card.holderName.length >= 1);
2855
2864
  const submit = useCallback6(async () => {
2856
2865
  setFormSubmitAttempted(true);
2857
2866
  setError(null);
@@ -3179,7 +3188,26 @@ function CheckoutPageDefault() {
3179
3188
  error: form.cpfError,
3180
3189
  valid: !!form.cpf && !form.cpfError
3181
3190
  }
3182
- )
3191
+ ),
3192
+ form.method === "card" ? /* @__PURE__ */ jsxs18(Fragment7, { children: [
3193
+ /* @__PURE__ */ jsx27("div", { className: "h-3" }),
3194
+ /* @__PURE__ */ jsx27(FieldLabel, { children: "Telefone" }),
3195
+ /* @__PURE__ */ jsx27(
3196
+ FieldInput,
3197
+ {
3198
+ type: "tel",
3199
+ inputMode: "tel",
3200
+ autoComplete: "tel",
3201
+ placeholder: "(11) 99999-9999",
3202
+ value: form.phone,
3203
+ onChange: form.setPhone,
3204
+ onBlur: form.markPhoneTouched,
3205
+ error: form.phoneError,
3206
+ valid: !!form.phone && !form.phoneError
3207
+ }
3208
+ ),
3209
+ !form.phoneError && /* @__PURE__ */ jsx27(FieldHint, { children: "Usado pra confirmar pagamento e tratar disputas." })
3210
+ ] }) : null
3183
3211
  ] }),
3184
3212
  /* @__PURE__ */ jsxs18("section", { className: "px-5 pt-5", children: [
3185
3213
  /* @__PURE__ */ jsx27(FieldLabel, { children: "Forma de pagamento" }),
@@ -3963,7 +3991,7 @@ function PreAuthShell({
3963
3991
 
3964
3992
  // src/OnboardingFlow.tsx
3965
3993
  import { useCallback as useCallback13, useEffect as useEffect16, useMemo as useMemo11, useRef as useRef7 } from "react";
3966
- import { usePersistedState as usePersistedState3, useHook as useHook20 } from "@hook-sdk/sdk";
3994
+ import { usePersistedState as usePersistedState4, useHook as useHook20 } from "@hook-sdk/sdk";
3967
3995
 
3968
3996
  // src/hooks/useOnboardingStep.ts
3969
3997
  import { createContext as createContext3, useContext as useContext4 } from "react";
@@ -3992,7 +4020,7 @@ function OnboardingFlow({
3992
4020
  onComplete,
3993
4021
  persistKey
3994
4022
  }) {
3995
- const [draft, setDraft, status] = usePersistedState3(persistKey, {});
4023
+ const [draft, setDraft, status] = usePersistedState4(persistKey, {});
3996
4024
  const draftRef = useRef7(draft);
3997
4025
  draftRef.current = draft;
3998
4026
  const idx = readPersistedStepIdx(draft);