@hook-sdk/template 0.4.1 → 0.4.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
@@ -466,7 +466,6 @@ interface InstallActions {
466
466
  promptInstall: () => Promise<boolean>;
467
467
  dismissSession: () => void;
468
468
  dismissPermanent: () => void;
469
- showIOSOtherHelp: () => void;
470
469
  copyLink: () => Promise<void>;
471
470
  reset: () => void;
472
471
  }
package/dist/index.d.ts CHANGED
@@ -466,7 +466,6 @@ interface InstallActions {
466
466
  promptInstall: () => Promise<boolean>;
467
467
  dismissSession: () => void;
468
468
  dismissPermanent: () => void;
469
- showIOSOtherHelp: () => void;
470
469
  copyLink: () => Promise<void>;
471
470
  reset: () => void;
472
471
  }
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/AppRoot.tsx
2
- import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef2, useState as useState12 } from "react";
2
+ import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef2, useState as useState11 } from "react";
3
3
  import { useHook as useHook8 } from "@hook-sdk/sdk";
4
4
 
5
5
  // src/internal/TemplateConfigContext.tsx
@@ -402,9 +402,6 @@ function useInstallPrompt(slug) {
402
402
  setIsDismissedPermanent(true);
403
403
  track("pwa_install_permanent_dismiss", { slug, platform, prior_skip_count: skipCount });
404
404
  }, [slug, platform, skipCount]);
405
- const showIOSOtherHelp = useCallback2(() => {
406
- track("pwa_install_ios_other_help_shown", { slug });
407
- }, [slug]);
408
405
  const copyLink = useCallback2(async () => {
409
406
  if (typeof navigator === "undefined" || typeof location === "undefined") return;
410
407
  try {
@@ -443,7 +440,6 @@ function useInstallPrompt(slug) {
443
440
  promptInstall,
444
441
  dismissSession,
445
442
  dismissPermanent,
446
- showIOSOtherHelp,
447
443
  copyLink,
448
444
  reset
449
445
  };
@@ -503,23 +499,22 @@ var INSTALL_COPY = {
503
499
  skipPermanent: "N\xE3o me pergunte mais"
504
500
  },
505
501
  iosOther: {
506
- title: "Abra no Safari pra instalar",
507
- subtitle: "No Chrome/Firefox/Edge do iPhone n\xE3o d\xE1 pra instalar PWA. Abra o link no Safari.",
508
- ctaPrimary: "Abrir no Safari",
509
- ctaSecondary: "Copiar link",
510
- copiedToast: "Link copiado. Cole no Safari.",
511
- skip: "Continuar mesmo assim",
512
- skipPermanent: "N\xE3o me pergunte mais",
513
- help: {
514
- step1: {
515
- title: "Toque em \u22EF ou no bot\xE3o compartilhar",
516
- subtitle: "Na barra inferior ou superior do navegador"
517
- },
518
- step2: {
519
- title: 'Escolha "Abrir no Safari"',
520
- subtitle: "O app vai abrir direto no Safari"
521
- }
522
- }
502
+ title: "Adicione \xE0 sua Tela de In\xEDcio",
503
+ subtitle: "Siga os 3 passos",
504
+ step1: {
505
+ title: "Toque em Compartilhar",
506
+ subtitle: "Geralmente no topo ou no menu do navegador"
507
+ },
508
+ step2: {
509
+ title: 'Role e toque em "Adicionar \xE0 Tela de In\xEDcio"',
510
+ iconLabel: "Adicionar \xE0 Tela de In\xEDcio"
511
+ },
512
+ step3: {
513
+ title: 'Toque em "Adicionar" pra confirmar',
514
+ buttonLabel: "Adicionar"
515
+ },
516
+ skip: "Continuar no navegador",
517
+ skipPermanent: "N\xE3o me pergunte mais"
523
518
  },
524
519
  inApp: {
525
520
  instagram: {
@@ -654,18 +649,6 @@ var primaryButtonStyle = {
654
649
  cursor: "pointer",
655
650
  marginBottom: 12
656
651
  };
657
- var secondaryButtonStyle = {
658
- width: "100%",
659
- padding: "12px 20px",
660
- background: "transparent",
661
- color: "var(--hook-color-primary)",
662
- border: "1px solid var(--hook-color-primary)",
663
- borderRadius: 999,
664
- fontSize: 15,
665
- fontWeight: 500,
666
- cursor: "pointer",
667
- marginBottom: 12
668
- };
669
652
  var skipLinkStyle = {
670
653
  display: "block",
671
654
  width: "100%",
@@ -1072,7 +1055,6 @@ function IOSafariVariant({
1072
1055
  }
1073
1056
 
1074
1057
  // src/components/InstallGate/variants/IOSOtherVariant.tsx
1075
- import { useState as useState4 } from "react";
1076
1058
  import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
1077
1059
  function IOSOtherVariant({
1078
1060
  state,
@@ -1080,101 +1062,84 @@ function IOSOtherVariant({
1080
1062
  }) {
1081
1063
  const copy = INSTALL_COPY.iosOther;
1082
1064
  const showPermanent = shouldShowPermanentOption(state);
1083
- const [copied, setCopied] = useState4(false);
1084
- const [helpOpen, setHelpOpen] = useState4(false);
1085
- const handleCopy = async () => {
1086
- await actions.copyLink();
1087
- setCopied(true);
1088
- setTimeout(() => setCopied(false), 2e3);
1089
- };
1090
- const handleShowHelp = () => {
1091
- if (!helpOpen) actions.showIOSOtherHelp();
1092
- setHelpOpen(true);
1093
- };
1094
1065
  return /* @__PURE__ */ jsxs7(InstallSplash, { title: copy.title, subtitle: copy.subtitle, children: [
1095
1066
  /* @__PURE__ */ jsx13(
1096
- "button",
1067
+ Step2,
1097
1068
  {
1098
- "data-testid": "install-prompt-cta-ios-other-primary",
1099
- type: "button",
1100
- onClick: handleShowHelp,
1101
- "aria-expanded": helpOpen,
1102
- style: primaryButtonStyle,
1103
- children: copy.ctaPrimary
1069
+ n: 1,
1070
+ title: copy.step1.title,
1071
+ subtitle: copy.step1.subtitle,
1072
+ visual: /* @__PURE__ */ jsx13(
1073
+ "div",
1074
+ {
1075
+ style: {
1076
+ display: "flex",
1077
+ justifyContent: "center",
1078
+ alignItems: "center",
1079
+ background: "#f5f5f7",
1080
+ borderRadius: 12,
1081
+ padding: "12px 0",
1082
+ marginTop: 8
1083
+ },
1084
+ children: /* @__PURE__ */ jsx13(ShareIconIOS, { size: 32, style: { color: "var(--hook-color-primary)" } })
1085
+ }
1086
+ )
1104
1087
  }
1105
1088
  ),
1106
1089
  /* @__PURE__ */ jsx13(
1107
- "button",
1090
+ Step2,
1108
1091
  {
1109
- "data-testid": "install-prompt-cta-ios-other-secondary",
1110
- type: "button",
1111
- onClick: () => void handleCopy(),
1112
- style: secondaryButtonStyle,
1113
- children: copied ? copy.copiedToast : copy.ctaSecondary
1092
+ n: 2,
1093
+ title: copy.step2.title,
1094
+ visual: /* @__PURE__ */ jsxs7(
1095
+ "div",
1096
+ {
1097
+ style: {
1098
+ display: "flex",
1099
+ alignItems: "center",
1100
+ gap: 10,
1101
+ background: "#f5f5f7",
1102
+ borderRadius: 12,
1103
+ padding: "12px 14px",
1104
+ marginTop: 8
1105
+ },
1106
+ children: [
1107
+ /* @__PURE__ */ jsx13(SquarePlusIcon, { size: 22, style: { color: "#555" } }),
1108
+ /* @__PURE__ */ jsx13("span", { style: { fontSize: 14, color: "#333" }, children: copy.step2.iconLabel })
1109
+ ]
1110
+ }
1111
+ )
1114
1112
  }
1115
1113
  ),
1116
- helpOpen && /* @__PURE__ */ jsxs7(
1117
- "div",
1114
+ /* @__PURE__ */ jsx13(
1115
+ Step2,
1118
1116
  {
1119
- "data-testid": "install-prompt-ios-other-help",
1120
- style: { marginTop: 20, textAlign: "left" },
1121
- children: [
1122
- /* @__PURE__ */ jsx13(
1123
- Step2,
1124
- {
1125
- n: 1,
1126
- title: copy.help.step1.title,
1127
- subtitle: copy.help.step1.subtitle,
1128
- visual: /* @__PURE__ */ jsx13(
1129
- "div",
1130
- {
1131
- style: {
1132
- display: "flex",
1133
- justifyContent: "center",
1134
- alignItems: "center",
1135
- background: "#f5f5f7",
1136
- borderRadius: 12,
1137
- padding: "12px 0",
1138
- marginTop: 8
1139
- },
1140
- children: /* @__PURE__ */ jsx13(
1141
- MenuDotsHorizontalIcon,
1142
- {
1143
- size: 28,
1144
- style: { color: "var(--hook-color-primary)" }
1145
- }
1146
- )
1147
- }
1148
- )
1149
- }
1150
- ),
1151
- /* @__PURE__ */ jsx13(
1152
- Step2,
1153
- {
1154
- n: 2,
1155
- title: copy.help.step2.title,
1156
- subtitle: copy.help.step2.subtitle,
1157
- visual: /* @__PURE__ */ jsxs7(
1158
- "div",
1159
- {
1160
- style: {
1161
- display: "flex",
1162
- alignItems: "center",
1163
- gap: 10,
1164
- background: "#f5f5f7",
1165
- borderRadius: 12,
1166
- padding: "12px 14px",
1167
- marginTop: 8
1168
- },
1169
- children: [
1170
- /* @__PURE__ */ jsx13(ExternalLinkIcon, { size: 22, style: { color: "#555" } }),
1171
- /* @__PURE__ */ jsx13("span", { style: { fontSize: 14, color: "#333" }, children: "Abrir no Safari" })
1172
- ]
1173
- }
1174
- )
1175
- }
1176
- )
1177
- ]
1117
+ n: 3,
1118
+ title: copy.step3.title,
1119
+ visual: /* @__PURE__ */ jsx13(
1120
+ "div",
1121
+ {
1122
+ style: {
1123
+ display: "flex",
1124
+ justifyContent: "flex-end",
1125
+ background: "#f5f5f7",
1126
+ borderRadius: 12,
1127
+ padding: "10px 14px",
1128
+ marginTop: 8
1129
+ },
1130
+ children: /* @__PURE__ */ jsx13(
1131
+ "span",
1132
+ {
1133
+ style: {
1134
+ color: "var(--hook-color-primary)",
1135
+ fontSize: 15,
1136
+ fontWeight: 600
1137
+ },
1138
+ children: copy.step3.buttonLabel
1139
+ }
1140
+ )
1141
+ }
1142
+ )
1178
1143
  }
1179
1144
  ),
1180
1145
  /* @__PURE__ */ jsx13(
@@ -1183,7 +1148,7 @@ function IOSOtherVariant({
1183
1148
  "data-testid": "install-prompt-skip-session",
1184
1149
  type: "button",
1185
1150
  onClick: actions.dismissSession,
1186
- style: skipLinkStyle,
1151
+ style: { ...skipLinkStyle, marginTop: 16 },
1187
1152
  children: copy.skip
1188
1153
  }
1189
1154
  ),
@@ -1201,7 +1166,7 @@ function IOSOtherVariant({
1201
1166
  }
1202
1167
 
1203
1168
  // src/components/InstallGate/variants/InAppBrowserVariant.tsx
1204
- import { useState as useState5 } from "react";
1169
+ import { useState as useState4 } from "react";
1205
1170
  import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
1206
1171
  function InAppBrowserVariant({
1207
1172
  state,
@@ -1211,7 +1176,7 @@ function InAppBrowserVariant({
1211
1176
  const appCopy = INSTALL_COPY.inApp[app] ?? INSTALL_COPY.inApp.other;
1212
1177
  const copy = INSTALL_COPY.inApp;
1213
1178
  const showPermanent = shouldShowPermanentOption(state);
1214
- const [copied, setCopied] = useState5(false);
1179
+ const [copied, setCopied] = useState4(false);
1215
1180
  const handleCopy = async () => {
1216
1181
  await actions.copyLink();
1217
1182
  setCopied(true);
@@ -1480,7 +1445,7 @@ var ErrorBoundary = class extends Component {
1480
1445
  };
1481
1446
 
1482
1447
  // src/hooks/useLoginForm.ts
1483
- import { useCallback as useCallback3, useMemo as useMemo2, useState as useState6 } from "react";
1448
+ import { useCallback as useCallback3, useMemo as useMemo2, useState as useState5 } from "react";
1484
1449
  import { useHook as useHook4 } from "@hook-sdk/sdk";
1485
1450
 
1486
1451
  // src/errors.ts
@@ -1517,10 +1482,10 @@ var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
1517
1482
  var MIN_PASSWORD = 8;
1518
1483
  function useLoginForm() {
1519
1484
  const { auth } = useHook4();
1520
- const [email, setEmail] = useState6("");
1521
- const [password, setPassword] = useState6("");
1522
- const [submitting, setSubmitting] = useState6(false);
1523
- const [error, setError] = useState6(null);
1485
+ const [email, setEmail] = useState5("");
1486
+ const [password, setPassword] = useState5("");
1487
+ const [submitting, setSubmitting] = useState5(false);
1488
+ const [error, setError] = useState5(null);
1524
1489
  const emailError = useMemo2(() => {
1525
1490
  if (email.length === 0) return null;
1526
1491
  if (!EMAIL_RE.test(email)) return "Formato de e-mail inv\xE1lido.";
@@ -1631,7 +1596,7 @@ function GoogleGlyph() {
1631
1596
  }
1632
1597
 
1633
1598
  // src/internal/OAuthErrorBanner.tsx
1634
- import { useEffect as useEffect5, useState as useState7 } from "react";
1599
+ import { useEffect as useEffect5, useState as useState6 } from "react";
1635
1600
  import { jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
1636
1601
  var ERROR_MESSAGES = {
1637
1602
  invalid_state: "Sess\xE3o expirou, tente de novo.",
@@ -1652,7 +1617,7 @@ function stripErrorFromUrl() {
1652
1617
  window.history.replaceState({}, "", url.toString());
1653
1618
  }
1654
1619
  function OAuthErrorBanner() {
1655
- const [code, setCode] = useState7(() => readErrorCode());
1620
+ const [code, setCode] = useState6(() => readErrorCode());
1656
1621
  useEffect5(() => {
1657
1622
  if (code !== null) stripErrorFromUrl();
1658
1623
  }, [code]);
@@ -1786,17 +1751,17 @@ function DefaultLoginScreen({ onNavigate }) {
1786
1751
  }
1787
1752
 
1788
1753
  // src/hooks/useSignupForm.ts
1789
- import { useCallback as useCallback4, useMemo as useMemo3, useState as useState8 } from "react";
1754
+ import { useCallback as useCallback4, useMemo as useMemo3, useState as useState7 } from "react";
1790
1755
  import { useHook as useHook5 } from "@hook-sdk/sdk";
1791
1756
  var EMAIL_RE2 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
1792
1757
  var MIN_PASSWORD2 = 8;
1793
1758
  function useSignupForm() {
1794
1759
  const { auth } = useHook5();
1795
- const [name, setName] = useState8("");
1796
- const [email, setEmail] = useState8("");
1797
- const [password, setPassword] = useState8("");
1798
- const [submitting, setSubmitting] = useState8(false);
1799
- const [error, setError] = useState8(null);
1760
+ const [name, setName] = useState7("");
1761
+ const [email, setEmail] = useState7("");
1762
+ const [password, setPassword] = useState7("");
1763
+ const [submitting, setSubmitting] = useState7(false);
1764
+ const [error, setError] = useState7(null);
1800
1765
  const nameError = useMemo3(() => {
1801
1766
  if (name.length === 0) return null;
1802
1767
  if (name.trim().length < 2) return "Nome muito curto.";
@@ -1901,15 +1866,15 @@ function DefaultSignupScreen({ onNavigate }) {
1901
1866
  }
1902
1867
 
1903
1868
  // src/hooks/useForgotForm.ts
1904
- import { useCallback as useCallback5, useMemo as useMemo4, useState as useState9 } from "react";
1869
+ import { useCallback as useCallback5, useMemo as useMemo4, useState as useState8 } from "react";
1905
1870
  import { useHook as useHook6 } from "@hook-sdk/sdk";
1906
1871
  var EMAIL_RE3 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
1907
1872
  function useForgotForm() {
1908
1873
  const { auth } = useHook6();
1909
- const [email, setEmail] = useState9("");
1910
- const [submitting, setSubmitting] = useState9(false);
1911
- const [sent, setSent] = useState9(false);
1912
- const [error, setError] = useState9(null);
1874
+ const [email, setEmail] = useState8("");
1875
+ const [submitting, setSubmitting] = useState8(false);
1876
+ const [sent, setSent] = useState8(false);
1877
+ const [error, setError] = useState8(null);
1913
1878
  const emailError = useMemo4(() => {
1914
1879
  if (email.length === 0) return null;
1915
1880
  if (!EMAIL_RE3.test(email)) return "Formato de e-mail inv\xE1lido.";
@@ -1975,17 +1940,17 @@ function DefaultForgotScreen({ onNavigate }) {
1975
1940
  }
1976
1941
 
1977
1942
  // src/hooks/useResetForm.ts
1978
- import { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo5, useState as useState10 } from "react";
1943
+ import { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo5, useState as useState9 } from "react";
1979
1944
  import { useHook as useHook7 } from "@hook-sdk/sdk";
1980
1945
  var MIN_PASSWORD3 = 12;
1981
1946
  function useResetForm() {
1982
1947
  const { auth } = useHook7();
1983
- const [token, setToken] = useState10(null);
1984
- const [password, setPassword] = useState10("");
1985
- const [confirm, setConfirm] = useState10("");
1986
- const [submitting, setSubmitting] = useState10(false);
1987
- const [done, setDone] = useState10(false);
1988
- const [error, setError] = useState10(null);
1948
+ const [token, setToken] = useState9(null);
1949
+ const [password, setPassword] = useState9("");
1950
+ const [confirm, setConfirm] = useState9("");
1951
+ const [submitting, setSubmitting] = useState9(false);
1952
+ const [done, setDone] = useState9(false);
1953
+ const [error, setError] = useState9(null);
1989
1954
  useEffect6(() => {
1990
1955
  if (typeof window === "undefined") return;
1991
1956
  const params = new URLSearchParams(window.location.search);
@@ -2081,13 +2046,13 @@ function DefaultResetScreen({ onNavigate }) {
2081
2046
  }
2082
2047
 
2083
2048
  // src/defaults/DefaultPaywall.tsx
2084
- import { useState as useState11 } from "react";
2049
+ import { useState as useState10 } from "react";
2085
2050
  import { jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
2086
2051
  function DefaultPaywall() {
2087
2052
  const config = useTemplateConfig();
2088
2053
  const { checkout, opening, error } = usePaywallState();
2089
2054
  const p = config.subscription.paywall_config;
2090
- const [cpf, setCpf] = useState11("");
2055
+ const [cpf, setCpf] = useState10("");
2091
2056
  const cpfDigits = cpf.replace(/\D/g, "");
2092
2057
  const canCheckout = cpfDigits.length === 11 && !opening;
2093
2058
  return /* @__PURE__ */ jsxs18("main", { style: { padding: 24, maxWidth: 440, margin: "0 auto", textAlign: "center" }, children: [
@@ -2147,7 +2112,7 @@ function PaymentReturnHandler({ children }) {
2147
2112
  const subRef = useRef2(subscription);
2148
2113
  subRef.current = subscription;
2149
2114
  const runIdRef = useRef2(0);
2150
- const [state, setState] = useState12("idle");
2115
+ const [state, setState] = useState11("idle");
2151
2116
  const runPoll = useCallback7(() => {
2152
2117
  const runId = ++runIdRef.current;
2153
2118
  setState("confirming");
@@ -2251,7 +2216,7 @@ function AppRoot({
2251
2216
  }
2252
2217
 
2253
2218
  // src/hooks/usePush.ts
2254
- import { useCallback as useCallback8, useEffect as useEffect8, useState as useState13 } from "react";
2219
+ import { useCallback as useCallback8, useEffect as useEffect8, useState as useState12 } from "react";
2255
2220
  import { useHook as useHook9 } from "@hook-sdk/sdk";
2256
2221
  function detectIosNeedsInstall() {
2257
2222
  if (typeof navigator === "undefined" || typeof window === "undefined") return false;
@@ -2279,7 +2244,7 @@ function deriveState(push) {
2279
2244
  }
2280
2245
  function usePush() {
2281
2246
  const { push } = useHook9();
2282
- const [state, setState] = useState13(() => deriveState(push));
2247
+ const [state, setState] = useState12(() => deriveState(push));
2283
2248
  useEffect8(() => {
2284
2249
  setState(deriveState(push));
2285
2250
  }, [push]);
@@ -2397,13 +2362,13 @@ function useSubscription() {
2397
2362
  }
2398
2363
 
2399
2364
  // src/hooks/useReminders.ts
2400
- import { useCallback as useCallback9, useEffect as useEffect10, useState as useState14 } from "react";
2365
+ import { useCallback as useCallback9, useEffect as useEffect10, useState as useState13 } from "react";
2401
2366
  import { useHook as useHook12 } from "@hook-sdk/sdk";
2402
2367
  function useReminders() {
2403
2368
  const { push } = useHook12();
2404
2369
  const r = push.reminders;
2405
- const [reminders, setReminders] = useState14([]);
2406
- const [loading, setLoading] = useState14(true);
2370
+ const [reminders, setReminders] = useState13([]);
2371
+ const [loading, setLoading] = useState13(true);
2407
2372
  const reload = useCallback9(async () => {
2408
2373
  setLoading(true);
2409
2374
  try {
@@ -2434,9 +2399,9 @@ function useReminders() {
2434
2399
  }
2435
2400
 
2436
2401
  // src/hooks/useToast.ts
2437
- import { useCallback as useCallback10, useState as useState15 } from "react";
2402
+ import { useCallback as useCallback10, useState as useState14 } from "react";
2438
2403
  function useToast() {
2439
- const [items, setItems] = useState15([]);
2404
+ const [items, setItems] = useState14([]);
2440
2405
  const show = useCallback10((message, kind = "info") => {
2441
2406
  const id = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
2442
2407
  setItems((prev) => [...prev, { id, message, kind }]);