@hook-sdk/template 0.12.0 → 0.13.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 +231 -171
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +190 -130
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -69,9 +69,9 @@ __export(index_exports, {
|
|
|
69
69
|
module.exports = __toCommonJS(index_exports);
|
|
70
70
|
|
|
71
71
|
// src/AppRoot.tsx
|
|
72
|
-
var
|
|
72
|
+
var import_react12 = require("react");
|
|
73
73
|
var import_react_router_dom2 = require("react-router-dom");
|
|
74
|
-
var
|
|
74
|
+
var import_sdk5 = require("@hook-sdk/sdk");
|
|
75
75
|
|
|
76
76
|
// src/config/AppConfigContext.tsx
|
|
77
77
|
var import_react = require("react");
|
|
@@ -1826,10 +1826,69 @@ function PushPrompt() {
|
|
|
1826
1826
|
return null;
|
|
1827
1827
|
}
|
|
1828
1828
|
|
|
1829
|
-
// src/
|
|
1829
|
+
// src/internal/SessionExpiredBanner.tsx
|
|
1830
1830
|
var import_react9 = require("react");
|
|
1831
|
+
var import_sdk3 = require("@hook-sdk/sdk");
|
|
1831
1832
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1832
|
-
var
|
|
1833
|
+
var DISMISS_KEY = "hook:session-expired-dismissed-until";
|
|
1834
|
+
var DISMISS_TTL_MS = 60 * 60 * 1e3;
|
|
1835
|
+
function SessionExpiredBanner() {
|
|
1836
|
+
const { authStatus } = (0, import_sdk3.useHook)();
|
|
1837
|
+
const wasAuthRef = (0, import_react9.useRef)(false);
|
|
1838
|
+
const [show, setShow] = (0, import_react9.useState)(false);
|
|
1839
|
+
(0, import_react9.useEffect)(() => {
|
|
1840
|
+
if (authStatus === "authenticated") {
|
|
1841
|
+
wasAuthRef.current = true;
|
|
1842
|
+
setShow(false);
|
|
1843
|
+
return;
|
|
1844
|
+
}
|
|
1845
|
+
if (authStatus === "anonymous" && wasAuthRef.current) {
|
|
1846
|
+
const until = Number(localStorage.getItem(DISMISS_KEY) ?? "0");
|
|
1847
|
+
if (Date.now() < until) {
|
|
1848
|
+
setShow(false);
|
|
1849
|
+
return;
|
|
1850
|
+
}
|
|
1851
|
+
setShow(true);
|
|
1852
|
+
}
|
|
1853
|
+
}, [authStatus]);
|
|
1854
|
+
if (!show) return null;
|
|
1855
|
+
function dismiss() {
|
|
1856
|
+
localStorage.setItem(DISMISS_KEY, String(Date.now() + DISMISS_TTL_MS));
|
|
1857
|
+
setShow(false);
|
|
1858
|
+
}
|
|
1859
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { role: "alert", className: "fixed top-0 inset-x-0 bg-red-600 text-white px-4 py-2 flex items-center justify-between gap-3 text-sm shadow", style: { zIndex: 10001 }, children: [
|
|
1860
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { children: [
|
|
1861
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("strong", { children: "Sua sess\xE3o expirou." }),
|
|
1862
|
+
" Fa\xE7a login novamente para continuar."
|
|
1863
|
+
] }),
|
|
1864
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1865
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1866
|
+
"button",
|
|
1867
|
+
{
|
|
1868
|
+
type: "button",
|
|
1869
|
+
onClick: dismiss,
|
|
1870
|
+
className: "px-3 py-1 bg-white text-red-700 rounded text-xs font-medium hover:bg-red-50",
|
|
1871
|
+
children: "Fazer login"
|
|
1872
|
+
}
|
|
1873
|
+
),
|
|
1874
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1875
|
+
"button",
|
|
1876
|
+
{
|
|
1877
|
+
type: "button",
|
|
1878
|
+
onClick: dismiss,
|
|
1879
|
+
"aria-label": "Fechar",
|
|
1880
|
+
className: "px-2 py-1 text-white/80 hover:text-white text-xs",
|
|
1881
|
+
children: "Fechar"
|
|
1882
|
+
}
|
|
1883
|
+
)
|
|
1884
|
+
] })
|
|
1885
|
+
] });
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
// src/defaults/ErrorBoundary.tsx
|
|
1889
|
+
var import_react10 = require("react");
|
|
1890
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1891
|
+
var ErrorBoundary = class extends import_react10.Component {
|
|
1833
1892
|
state = { error: null };
|
|
1834
1893
|
static getDerivedStateFromError(error) {
|
|
1835
1894
|
return { error };
|
|
@@ -1846,27 +1905,27 @@ var ErrorBoundary = class extends import_react9.Component {
|
|
|
1846
1905
|
}
|
|
1847
1906
|
render() {
|
|
1848
1907
|
if (this.state.error) {
|
|
1849
|
-
return this.props.fallback ?? /* @__PURE__ */ (0,
|
|
1850
|
-
/* @__PURE__ */ (0,
|
|
1851
|
-
/* @__PURE__ */ (0,
|
|
1908
|
+
return this.props.fallback ?? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { role: "alert", style: { padding: 24, textAlign: "center" }, children: [
|
|
1909
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h2", { children: "Algo deu errado" }),
|
|
1910
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { style: { opacity: 0.7 }, children: "Recarregue a p\xE1gina pra tentar de novo." })
|
|
1852
1911
|
] });
|
|
1853
1912
|
}
|
|
1854
|
-
return /* @__PURE__ */ (0,
|
|
1913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: this.props.children });
|
|
1855
1914
|
}
|
|
1856
1915
|
};
|
|
1857
1916
|
|
|
1858
1917
|
// src/internal/PaymentReturnHandler.tsx
|
|
1859
|
-
var
|
|
1860
|
-
var
|
|
1861
|
-
var
|
|
1918
|
+
var import_react11 = require("react");
|
|
1919
|
+
var import_sdk4 = require("@hook-sdk/sdk");
|
|
1920
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1862
1921
|
var BACKOFF_MS = [2e3, 5e3, 1e4, 2e4, 4e4];
|
|
1863
1922
|
function PaymentReturnHandler({ children }) {
|
|
1864
|
-
const { subscription } = (0,
|
|
1865
|
-
const subRef = (0,
|
|
1923
|
+
const { subscription } = (0, import_sdk4.useHook)();
|
|
1924
|
+
const subRef = (0, import_react11.useRef)(subscription);
|
|
1866
1925
|
subRef.current = subscription;
|
|
1867
|
-
const runIdRef = (0,
|
|
1868
|
-
const [state, setState] = (0,
|
|
1869
|
-
const runPoll = (0,
|
|
1926
|
+
const runIdRef = (0, import_react11.useRef)(0);
|
|
1927
|
+
const [state, setState] = (0, import_react11.useState)("idle");
|
|
1928
|
+
const runPoll = (0, import_react11.useCallback)(() => {
|
|
1870
1929
|
const runId = ++runIdRef.current;
|
|
1871
1930
|
setState("confirming");
|
|
1872
1931
|
let attempts = 0;
|
|
@@ -1895,7 +1954,7 @@ function PaymentReturnHandler({ children }) {
|
|
|
1895
1954
|
};
|
|
1896
1955
|
void tick();
|
|
1897
1956
|
}, []);
|
|
1898
|
-
(0,
|
|
1957
|
+
(0, import_react11.useEffect)(() => {
|
|
1899
1958
|
if (typeof window === "undefined") return;
|
|
1900
1959
|
const url = new URL(window.location.href);
|
|
1901
1960
|
if (url.searchParams.get("paymentReturn") !== "1") return;
|
|
@@ -1905,15 +1964,15 @@ function PaymentReturnHandler({ children }) {
|
|
|
1905
1964
|
};
|
|
1906
1965
|
}, [runPoll]);
|
|
1907
1966
|
if (state === "confirming") {
|
|
1908
|
-
return /* @__PURE__ */ (0,
|
|
1967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { role: "status", "aria-live": "polite", style: overlayStyle2, children: "Confirmando pagamento\u2026" });
|
|
1909
1968
|
}
|
|
1910
1969
|
if (state === "waiting") {
|
|
1911
|
-
return /* @__PURE__ */ (0,
|
|
1912
|
-
/* @__PURE__ */ (0,
|
|
1913
|
-
/* @__PURE__ */ (0,
|
|
1970
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { role: "status", "aria-live": "polite", style: overlayStyle2, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { maxWidth: 320, textAlign: "center", lineHeight: 1.5 }, children: [
|
|
1971
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { marginBottom: 16 }, children: "Pagamento aceito. Estamos confirmando com o banco \u2014 pode levar alguns minutos." }),
|
|
1972
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", onClick: runPoll, style: buttonStyle, children: "Atualizar" })
|
|
1914
1973
|
] }) });
|
|
1915
1974
|
}
|
|
1916
|
-
return /* @__PURE__ */ (0,
|
|
1975
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
|
|
1917
1976
|
}
|
|
1918
1977
|
var overlayStyle2 = {
|
|
1919
1978
|
position: "fixed",
|
|
@@ -1939,7 +1998,7 @@ var buttonStyle = {
|
|
|
1939
1998
|
};
|
|
1940
1999
|
|
|
1941
2000
|
// src/AppRoot.tsx
|
|
1942
|
-
var
|
|
2001
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1943
2002
|
function buildLegacyConfigShim(config) {
|
|
1944
2003
|
const paywall = config.paywall;
|
|
1945
2004
|
const isFree = paywall.mode === "free";
|
|
@@ -2003,13 +2062,14 @@ function AppRoot(props) {
|
|
|
2003
2062
|
"[hook-template] <AppRoot>: PreAuthFlow slot prop is required when config.onboarding.trigger === 'pre_signup_custom'."
|
|
2004
2063
|
);
|
|
2005
2064
|
}
|
|
2006
|
-
const legacyShim = (0,
|
|
2065
|
+
const legacyShim = (0, import_react12.useMemo)(() => buildLegacyConfigShim(config), [config]);
|
|
2007
2066
|
const Router = testRouter === "memory" ? import_react_router_dom2.MemoryRouter : import_react_router_dom2.BrowserRouter;
|
|
2008
2067
|
const basename = `/app/${config.slug}`;
|
|
2009
2068
|
const routerProps = testRouter === "memory" ? { basename, initialEntries: testInitialEntries } : { basename };
|
|
2010
|
-
return /* @__PURE__ */ (0,
|
|
2011
|
-
/* @__PURE__ */ (0,
|
|
2012
|
-
/* @__PURE__ */ (0,
|
|
2069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AppConfigProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TemplateConfigProvider, { config: legacyShim, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PersistenceRegistry, { config: config.persistedKeys, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Router, { ...routerProps, children: [
|
|
2070
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DeepLinkHandler, { deepLinks: config.deepLinks }),
|
|
2071
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SessionExpiredBanner, {}),
|
|
2072
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(InstallGate, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2013
2073
|
AuthGated,
|
|
2014
2074
|
{
|
|
2015
2075
|
config,
|
|
@@ -2021,9 +2081,9 @@ function AppRoot(props) {
|
|
|
2021
2081
|
Paywall,
|
|
2022
2082
|
Onboarding,
|
|
2023
2083
|
PreAuthFlow,
|
|
2024
|
-
children: /* @__PURE__ */ (0,
|
|
2084
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(SubscriptionGate, { Paywall: Paywall ?? FallbackPaywall, children: [
|
|
2025
2085
|
children,
|
|
2026
|
-
/* @__PURE__ */ (0,
|
|
2086
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PushPrompt, {})
|
|
2027
2087
|
] })
|
|
2028
2088
|
}
|
|
2029
2089
|
) })
|
|
@@ -2039,39 +2099,39 @@ function AuthGated({
|
|
|
2039
2099
|
EmailVerify,
|
|
2040
2100
|
PreAuthFlow
|
|
2041
2101
|
}) {
|
|
2042
|
-
const { authStatus } = (0,
|
|
2102
|
+
const { authStatus } = (0, import_sdk5.useHook)();
|
|
2043
2103
|
if (authStatus === "loading") return null;
|
|
2044
2104
|
if (authStatus !== "authenticated") {
|
|
2045
2105
|
if (config.onboarding?.trigger === "pre_signup_custom" && PreAuthFlow) {
|
|
2046
|
-
return /* @__PURE__ */ (0,
|
|
2047
|
-
/* @__PURE__ */ (0,
|
|
2048
|
-
/* @__PURE__ */ (0,
|
|
2049
|
-
/* @__PURE__ */ (0,
|
|
2050
|
-
/* @__PURE__ */ (0,
|
|
2051
|
-
EmailVerify ? /* @__PURE__ */ (0,
|
|
2052
|
-
/* @__PURE__ */ (0,
|
|
2106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_react_router_dom2.Routes, { children: [
|
|
2107
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Route, { path: "/signin", element: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Login, {}) }),
|
|
2108
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Route, { path: "/signup", element: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Signup, {}) }),
|
|
2109
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Route, { path: "/forgot", element: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Forgot, {}) }),
|
|
2110
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Route, { path: "/reset", element: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Reset, {}) }),
|
|
2111
|
+
EmailVerify ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Route, { path: "/verify", element: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EmailVerify, {}) }) : null,
|
|
2112
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Route, { path: "/*", element: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PreAuthFlow, {}) })
|
|
2053
2113
|
] });
|
|
2054
2114
|
}
|
|
2055
|
-
return /* @__PURE__ */ (0,
|
|
2056
|
-
/* @__PURE__ */ (0,
|
|
2057
|
-
/* @__PURE__ */ (0,
|
|
2058
|
-
/* @__PURE__ */ (0,
|
|
2059
|
-
/* @__PURE__ */ (0,
|
|
2060
|
-
EmailVerify ? /* @__PURE__ */ (0,
|
|
2061
|
-
/* @__PURE__ */ (0,
|
|
2115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_react_router_dom2.Routes, { children: [
|
|
2116
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Route, { path: "/", element: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Login, {}) }),
|
|
2117
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Route, { path: "/signup", element: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Signup, {}) }),
|
|
2118
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Route, { path: "/forgot", element: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Forgot, {}) }),
|
|
2119
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Route, { path: "/reset", element: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Reset, {}) }),
|
|
2120
|
+
EmailVerify ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Route, { path: "/verify", element: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EmailVerify, {}) }) : null,
|
|
2121
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Route, { path: "*", element: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_router_dom2.Navigate, { to: "/", replace: true }) })
|
|
2062
2122
|
] });
|
|
2063
2123
|
}
|
|
2064
|
-
return /* @__PURE__ */ (0,
|
|
2124
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
2065
2125
|
}
|
|
2066
2126
|
function FallbackPaywall() {
|
|
2067
2127
|
return null;
|
|
2068
2128
|
}
|
|
2069
2129
|
|
|
2070
2130
|
// src/hooks/usePush.ts
|
|
2071
|
-
var
|
|
2072
|
-
var
|
|
2131
|
+
var import_react13 = require("react");
|
|
2132
|
+
var import_sdk6 = require("@hook-sdk/sdk");
|
|
2073
2133
|
var DISMISS_STORAGE_KEY = "push:dismissed-until";
|
|
2074
|
-
var
|
|
2134
|
+
var DISMISS_TTL_MS2 = 7 * 24 * 60 * 60 * 1e3;
|
|
2075
2135
|
function detectIosNeedsInstall() {
|
|
2076
2136
|
if (typeof navigator === "undefined" || typeof window === "undefined") return false;
|
|
2077
2137
|
const ua = navigator.userAgent || "";
|
|
@@ -2113,12 +2173,12 @@ function deriveState(push) {
|
|
|
2113
2173
|
return { kind: "prompt" };
|
|
2114
2174
|
}
|
|
2115
2175
|
function usePush() {
|
|
2116
|
-
const { push } = (0,
|
|
2117
|
-
const [state, setState] = (0,
|
|
2118
|
-
(0,
|
|
2176
|
+
const { push } = (0, import_sdk6.useHook)();
|
|
2177
|
+
const [state, setState] = (0, import_react13.useState)(() => deriveState(push));
|
|
2178
|
+
(0, import_react13.useEffect)(() => {
|
|
2119
2179
|
setState(deriveState(push));
|
|
2120
2180
|
}, [push]);
|
|
2121
|
-
const subscribe = (0,
|
|
2181
|
+
const subscribe = (0, import_react13.useCallback)(async () => {
|
|
2122
2182
|
try {
|
|
2123
2183
|
await push.subscribe();
|
|
2124
2184
|
setState({ kind: "subscribed" });
|
|
@@ -2130,7 +2190,7 @@ function usePush() {
|
|
|
2130
2190
|
throw e;
|
|
2131
2191
|
}
|
|
2132
2192
|
}, [push]);
|
|
2133
|
-
const unsubscribe = (0,
|
|
2193
|
+
const unsubscribe = (0, import_react13.useCallback)(async () => {
|
|
2134
2194
|
try {
|
|
2135
2195
|
await push.unsubscribe();
|
|
2136
2196
|
setState({ kind: "prompt" });
|
|
@@ -2139,10 +2199,10 @@ function usePush() {
|
|
|
2139
2199
|
throw e;
|
|
2140
2200
|
}
|
|
2141
2201
|
}, [push]);
|
|
2142
|
-
const dismiss = (0,
|
|
2202
|
+
const dismiss = (0, import_react13.useCallback)(() => {
|
|
2143
2203
|
if (typeof localStorage !== "undefined") {
|
|
2144
2204
|
try {
|
|
2145
|
-
localStorage.setItem(DISMISS_STORAGE_KEY, String(Date.now() +
|
|
2205
|
+
localStorage.setItem(DISMISS_STORAGE_KEY, String(Date.now() + DISMISS_TTL_MS2));
|
|
2146
2206
|
} catch {
|
|
2147
2207
|
}
|
|
2148
2208
|
}
|
|
@@ -2152,7 +2212,7 @@ function usePush() {
|
|
|
2152
2212
|
}
|
|
2153
2213
|
|
|
2154
2214
|
// src/components/PushPrompt.tsx
|
|
2155
|
-
var
|
|
2215
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2156
2216
|
function platformRecoveryCopy(texts) {
|
|
2157
2217
|
if (typeof navigator === "undefined") return null;
|
|
2158
2218
|
const ua = navigator.userAgent || "";
|
|
@@ -2175,28 +2235,28 @@ function PushPrompt2({ texts, onSubscribed, onDeclined, onInstallRequested, clas
|
|
|
2175
2235
|
const { state, subscribe } = usePush();
|
|
2176
2236
|
if (state.kind === "subscribed" || state.kind === "dismissed") return null;
|
|
2177
2237
|
if (state.kind === "ios_needs_install") {
|
|
2178
|
-
return /* @__PURE__ */ (0,
|
|
2179
|
-
/* @__PURE__ */ (0,
|
|
2180
|
-
/* @__PURE__ */ (0,
|
|
2181
|
-
onInstallRequested && texts.iosInstallCta && /* @__PURE__ */ (0,
|
|
2238
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className, role: "region", "aria-label": texts.iosInstallTitle, children: [
|
|
2239
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h3", { children: texts.iosInstallTitle }),
|
|
2240
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { children: texts.iosInstallBody }),
|
|
2241
|
+
onInstallRequested && texts.iosInstallCta && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { onClick: onInstallRequested, children: texts.iosInstallCta })
|
|
2182
2242
|
] });
|
|
2183
2243
|
}
|
|
2184
2244
|
if (state.kind === "denied") {
|
|
2185
2245
|
const recovery = platformRecoveryCopy(texts);
|
|
2186
|
-
return /* @__PURE__ */ (0,
|
|
2187
|
-
/* @__PURE__ */ (0,
|
|
2188
|
-
/* @__PURE__ */ (0,
|
|
2189
|
-
recovery && /* @__PURE__ */ (0,
|
|
2246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className, role: "region", "aria-label": texts.deniedTitle, children: [
|
|
2247
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h3", { children: texts.deniedTitle }),
|
|
2248
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { children: texts.deniedBody }),
|
|
2249
|
+
recovery && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { "data-testid": "denied-recovery", children: recovery })
|
|
2190
2250
|
] });
|
|
2191
2251
|
}
|
|
2192
2252
|
if (state.kind === "unsupported") {
|
|
2193
|
-
return /* @__PURE__ */ (0,
|
|
2253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className, role: "region", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { children: texts.unsupportedBody }) });
|
|
2194
2254
|
}
|
|
2195
2255
|
if (state.kind === "error") {
|
|
2196
|
-
return /* @__PURE__ */ (0,
|
|
2256
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className, role: "region", "aria-label": "error", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { children: state.message }) });
|
|
2197
2257
|
}
|
|
2198
|
-
return /* @__PURE__ */ (0,
|
|
2199
|
-
/* @__PURE__ */ (0,
|
|
2258
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className, role: "region", children: [
|
|
2259
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2200
2260
|
"button",
|
|
2201
2261
|
{
|
|
2202
2262
|
type: "button",
|
|
@@ -2210,41 +2270,41 @@ function PushPrompt2({ texts, onSubscribed, onDeclined, onInstallRequested, clas
|
|
|
2210
2270
|
children: texts.cta
|
|
2211
2271
|
}
|
|
2212
2272
|
),
|
|
2213
|
-
onDeclined && /* @__PURE__ */ (0,
|
|
2273
|
+
onDeclined && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", onClick: onDeclined, children: texts.declineCta })
|
|
2214
2274
|
] });
|
|
2215
2275
|
}
|
|
2216
2276
|
|
|
2217
2277
|
// src/defaults/LoadingState.tsx
|
|
2218
|
-
var
|
|
2278
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2219
2279
|
function LoadingState({ message }) {
|
|
2220
|
-
return /* @__PURE__ */ (0,
|
|
2280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { role: "status", "aria-live": "polite", style: { padding: 24, textAlign: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: message ?? "Carregando..." }) });
|
|
2221
2281
|
}
|
|
2222
2282
|
|
|
2223
2283
|
// src/defaults/EmptyState.tsx
|
|
2224
|
-
var
|
|
2284
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2225
2285
|
function EmptyState({ title, description, action }) {
|
|
2226
|
-
return /* @__PURE__ */ (0,
|
|
2227
|
-
/* @__PURE__ */ (0,
|
|
2228
|
-
description && /* @__PURE__ */ (0,
|
|
2229
|
-
action && /* @__PURE__ */ (0,
|
|
2286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { role: "status", style: { padding: 32, textAlign: "center" }, children: [
|
|
2287
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h2", { style: { marginBottom: 8 }, children: title }),
|
|
2288
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { style: { opacity: 0.7 }, children: description }),
|
|
2289
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { style: { marginTop: 16 }, children: action })
|
|
2230
2290
|
] });
|
|
2231
2291
|
}
|
|
2232
2292
|
|
|
2233
2293
|
// src/hooks/useLoginForm.ts
|
|
2234
|
-
var
|
|
2235
|
-
var
|
|
2294
|
+
var import_react14 = require("react");
|
|
2295
|
+
var import_sdk8 = require("@hook-sdk/sdk");
|
|
2236
2296
|
|
|
2237
2297
|
// src/errors.ts
|
|
2238
|
-
var
|
|
2298
|
+
var import_sdk7 = require("@hook-sdk/sdk");
|
|
2239
2299
|
function mapSdkError(err) {
|
|
2240
|
-
if (err instanceof
|
|
2300
|
+
if (err instanceof import_sdk7.SdkRateLimitError) {
|
|
2241
2301
|
return {
|
|
2242
2302
|
code: "rate_limited",
|
|
2243
2303
|
message: `Aguarde ${err.retryAfter}s e tente novamente.`,
|
|
2244
2304
|
retryAfter: err.retryAfter
|
|
2245
2305
|
};
|
|
2246
2306
|
}
|
|
2247
|
-
if (err instanceof
|
|
2307
|
+
if (err instanceof import_sdk7.SdkAuthError) {
|
|
2248
2308
|
const detail = err.detail;
|
|
2249
2309
|
if (detail === "email_unverified") {
|
|
2250
2310
|
return { code: "email_unverified", message: "Confirme seu e-mail antes de entrar." };
|
|
@@ -2254,7 +2314,7 @@ function mapSdkError(err) {
|
|
|
2254
2314
|
}
|
|
2255
2315
|
return { code: "invalid_credentials", message: "E-mail ou senha inv\xE1lidos." };
|
|
2256
2316
|
}
|
|
2257
|
-
if (err instanceof
|
|
2317
|
+
if (err instanceof import_sdk7.SdkError && err.httpStatus === 0) {
|
|
2258
2318
|
return { code: "network", message: "Sem conex\xE3o com o servidor. Verifique sua internet." };
|
|
2259
2319
|
}
|
|
2260
2320
|
if (err instanceof TypeError) {
|
|
@@ -2267,23 +2327,23 @@ function mapSdkError(err) {
|
|
|
2267
2327
|
var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
2268
2328
|
var MIN_PASSWORD = 8;
|
|
2269
2329
|
function useLoginForm() {
|
|
2270
|
-
const { auth } = (0,
|
|
2271
|
-
const [email, setEmail] = (0,
|
|
2272
|
-
const [password, setPassword] = (0,
|
|
2273
|
-
const [submitting, setSubmitting] = (0,
|
|
2274
|
-
const [error, setError] = (0,
|
|
2275
|
-
const emailError = (0,
|
|
2330
|
+
const { auth } = (0, import_sdk8.useHook)();
|
|
2331
|
+
const [email, setEmail] = (0, import_react14.useState)("");
|
|
2332
|
+
const [password, setPassword] = (0, import_react14.useState)("");
|
|
2333
|
+
const [submitting, setSubmitting] = (0, import_react14.useState)(false);
|
|
2334
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
2335
|
+
const emailError = (0, import_react14.useMemo)(() => {
|
|
2276
2336
|
if (email.length === 0) return null;
|
|
2277
2337
|
if (!EMAIL_RE.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
2278
2338
|
return null;
|
|
2279
2339
|
}, [email]);
|
|
2280
|
-
const passwordError = (0,
|
|
2340
|
+
const passwordError = (0, import_react14.useMemo)(() => {
|
|
2281
2341
|
if (password.length === 0) return null;
|
|
2282
2342
|
if (password.length < MIN_PASSWORD) return `M\xEDnimo de ${MIN_PASSWORD} caracteres.`;
|
|
2283
2343
|
return null;
|
|
2284
2344
|
}, [password]);
|
|
2285
2345
|
const canSubmit = email.length > 0 && password.length >= MIN_PASSWORD && emailError === null && passwordError === null && !submitting;
|
|
2286
|
-
const submit = (0,
|
|
2346
|
+
const submit = (0, import_react14.useCallback)(async () => {
|
|
2287
2347
|
if (!canSubmit) return false;
|
|
2288
2348
|
setSubmitting(true);
|
|
2289
2349
|
setError(null);
|
|
@@ -2313,34 +2373,34 @@ function useLoginForm() {
|
|
|
2313
2373
|
}
|
|
2314
2374
|
|
|
2315
2375
|
// src/hooks/useSignupForm.ts
|
|
2316
|
-
var
|
|
2317
|
-
var
|
|
2376
|
+
var import_react15 = require("react");
|
|
2377
|
+
var import_sdk9 = require("@hook-sdk/sdk");
|
|
2318
2378
|
var EMAIL_RE2 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
2319
2379
|
var MIN_PASSWORD2 = 8;
|
|
2320
2380
|
function useSignupForm() {
|
|
2321
|
-
const { auth } = (0,
|
|
2322
|
-
const [name, setName] = (0,
|
|
2323
|
-
const [email, setEmail] = (0,
|
|
2324
|
-
const [password, setPassword] = (0,
|
|
2325
|
-
const [submitting, setSubmitting] = (0,
|
|
2326
|
-
const [error, setError] = (0,
|
|
2327
|
-
const nameError = (0,
|
|
2381
|
+
const { auth } = (0, import_sdk9.useHook)();
|
|
2382
|
+
const [name, setName] = (0, import_react15.useState)("");
|
|
2383
|
+
const [email, setEmail] = (0, import_react15.useState)("");
|
|
2384
|
+
const [password, setPassword] = (0, import_react15.useState)("");
|
|
2385
|
+
const [submitting, setSubmitting] = (0, import_react15.useState)(false);
|
|
2386
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
2387
|
+
const nameError = (0, import_react15.useMemo)(() => {
|
|
2328
2388
|
if (name.length === 0) return null;
|
|
2329
2389
|
if (name.trim().length < 2) return "Nome muito curto.";
|
|
2330
2390
|
return null;
|
|
2331
2391
|
}, [name]);
|
|
2332
|
-
const emailError = (0,
|
|
2392
|
+
const emailError = (0, import_react15.useMemo)(() => {
|
|
2333
2393
|
if (email.length === 0) return null;
|
|
2334
2394
|
if (!EMAIL_RE2.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
2335
2395
|
return null;
|
|
2336
2396
|
}, [email]);
|
|
2337
|
-
const passwordError = (0,
|
|
2397
|
+
const passwordError = (0, import_react15.useMemo)(() => {
|
|
2338
2398
|
if (password.length === 0) return null;
|
|
2339
2399
|
if (password.length < MIN_PASSWORD2) return `M\xEDnimo de ${MIN_PASSWORD2} caracteres.`;
|
|
2340
2400
|
return null;
|
|
2341
2401
|
}, [password]);
|
|
2342
2402
|
const canSubmit = name.trim().length >= 2 && email.length > 0 && password.length >= MIN_PASSWORD2 && nameError === null && emailError === null && passwordError === null && !submitting;
|
|
2343
|
-
const submit = (0,
|
|
2403
|
+
const submit = (0, import_react15.useCallback)(async () => {
|
|
2344
2404
|
if (!canSubmit) return false;
|
|
2345
2405
|
setSubmitting(true);
|
|
2346
2406
|
setError(null);
|
|
@@ -2373,22 +2433,22 @@ function useSignupForm() {
|
|
|
2373
2433
|
}
|
|
2374
2434
|
|
|
2375
2435
|
// src/hooks/useForgotForm.ts
|
|
2376
|
-
var
|
|
2377
|
-
var
|
|
2436
|
+
var import_react16 = require("react");
|
|
2437
|
+
var import_sdk10 = require("@hook-sdk/sdk");
|
|
2378
2438
|
var EMAIL_RE3 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
2379
2439
|
function useForgotForm() {
|
|
2380
|
-
const { auth } = (0,
|
|
2381
|
-
const [email, setEmail] = (0,
|
|
2382
|
-
const [submitting, setSubmitting] = (0,
|
|
2383
|
-
const [sent, setSent] = (0,
|
|
2384
|
-
const [error, setError] = (0,
|
|
2385
|
-
const emailError = (0,
|
|
2440
|
+
const { auth } = (0, import_sdk10.useHook)();
|
|
2441
|
+
const [email, setEmail] = (0, import_react16.useState)("");
|
|
2442
|
+
const [submitting, setSubmitting] = (0, import_react16.useState)(false);
|
|
2443
|
+
const [sent, setSent] = (0, import_react16.useState)(false);
|
|
2444
|
+
const [error, setError] = (0, import_react16.useState)(null);
|
|
2445
|
+
const emailError = (0, import_react16.useMemo)(() => {
|
|
2386
2446
|
if (email.length === 0) return null;
|
|
2387
2447
|
if (!EMAIL_RE3.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
2388
2448
|
return null;
|
|
2389
2449
|
}, [email]);
|
|
2390
2450
|
const canSubmit = email.length > 0 && emailError === null && !submitting;
|
|
2391
|
-
const submit = (0,
|
|
2451
|
+
const submit = (0, import_react16.useCallback)(async () => {
|
|
2392
2452
|
if (!canSubmit) return false;
|
|
2393
2453
|
setSubmitting(true);
|
|
2394
2454
|
setError(null);
|
|
@@ -2416,35 +2476,35 @@ function useForgotForm() {
|
|
|
2416
2476
|
}
|
|
2417
2477
|
|
|
2418
2478
|
// src/hooks/useResetForm.ts
|
|
2419
|
-
var
|
|
2420
|
-
var
|
|
2479
|
+
var import_react17 = require("react");
|
|
2480
|
+
var import_sdk11 = require("@hook-sdk/sdk");
|
|
2421
2481
|
var MIN_PASSWORD3 = 12;
|
|
2422
2482
|
function useResetForm() {
|
|
2423
|
-
const { auth } = (0,
|
|
2424
|
-
const [token, setToken] = (0,
|
|
2425
|
-
const [password, setPassword] = (0,
|
|
2426
|
-
const [confirm, setConfirm] = (0,
|
|
2427
|
-
const [submitting, setSubmitting] = (0,
|
|
2428
|
-
const [done, setDone] = (0,
|
|
2429
|
-
const [error, setError] = (0,
|
|
2430
|
-
(0,
|
|
2483
|
+
const { auth } = (0, import_sdk11.useHook)();
|
|
2484
|
+
const [token, setToken] = (0, import_react17.useState)(null);
|
|
2485
|
+
const [password, setPassword] = (0, import_react17.useState)("");
|
|
2486
|
+
const [confirm, setConfirm] = (0, import_react17.useState)("");
|
|
2487
|
+
const [submitting, setSubmitting] = (0, import_react17.useState)(false);
|
|
2488
|
+
const [done, setDone] = (0, import_react17.useState)(false);
|
|
2489
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
2490
|
+
(0, import_react17.useEffect)(() => {
|
|
2431
2491
|
if (typeof window === "undefined") return;
|
|
2432
2492
|
const params = new URLSearchParams(window.location.search);
|
|
2433
2493
|
const t = params.get("token");
|
|
2434
2494
|
setToken(t && t.length > 0 ? t : null);
|
|
2435
2495
|
}, []);
|
|
2436
|
-
const passwordError = (0,
|
|
2496
|
+
const passwordError = (0, import_react17.useMemo)(() => {
|
|
2437
2497
|
if (password.length === 0) return null;
|
|
2438
2498
|
if (password.length < MIN_PASSWORD3) return `M\xEDnimo de ${MIN_PASSWORD3} caracteres.`;
|
|
2439
2499
|
return null;
|
|
2440
2500
|
}, [password]);
|
|
2441
|
-
const confirmError = (0,
|
|
2501
|
+
const confirmError = (0, import_react17.useMemo)(() => {
|
|
2442
2502
|
if (confirm.length === 0) return null;
|
|
2443
2503
|
if (confirm !== password) return "Senhas n\xE3o coincidem.";
|
|
2444
2504
|
return null;
|
|
2445
2505
|
}, [confirm, password]);
|
|
2446
2506
|
const canSubmit = token !== null && password.length >= MIN_PASSWORD3 && confirm === password && passwordError === null && confirmError === null && !submitting && !done;
|
|
2447
|
-
const submit = (0,
|
|
2507
|
+
const submit = (0, import_react17.useCallback)(async () => {
|
|
2448
2508
|
if (!canSubmit || token === null) return;
|
|
2449
2509
|
setSubmitting(true);
|
|
2450
2510
|
setError(null);
|
|
@@ -2480,9 +2540,9 @@ function useResetForm() {
|
|
|
2480
2540
|
}
|
|
2481
2541
|
|
|
2482
2542
|
// src/hooks/usePlan.ts
|
|
2483
|
-
var
|
|
2543
|
+
var import_sdk12 = require("@hook-sdk/sdk");
|
|
2484
2544
|
function usePlan() {
|
|
2485
|
-
const { plan } = (0,
|
|
2545
|
+
const { plan } = (0, import_sdk12.useHook)();
|
|
2486
2546
|
return plan;
|
|
2487
2547
|
}
|
|
2488
2548
|
|
|
@@ -2515,12 +2575,12 @@ function discountPercent(anchorCents, realCents) {
|
|
|
2515
2575
|
}
|
|
2516
2576
|
|
|
2517
2577
|
// src/hooks/useAuthPrimitives.ts
|
|
2518
|
-
var
|
|
2519
|
-
var
|
|
2578
|
+
var import_react18 = require("react");
|
|
2579
|
+
var import_sdk13 = require("@hook-sdk/sdk");
|
|
2520
2580
|
var warned = false;
|
|
2521
2581
|
function useAuthPrimitives() {
|
|
2522
|
-
const { auth } = (0,
|
|
2523
|
-
(0,
|
|
2582
|
+
const { auth } = (0, import_sdk13.useHook)();
|
|
2583
|
+
(0, import_react18.useEffect)(() => {
|
|
2524
2584
|
if (!warned && process.env.NODE_ENV !== "production") {
|
|
2525
2585
|
warned = true;
|
|
2526
2586
|
console.warn(
|
|
@@ -2542,9 +2602,9 @@ function useAuthPrimitives() {
|
|
|
2542
2602
|
}
|
|
2543
2603
|
|
|
2544
2604
|
// src/hooks/useAuth.ts
|
|
2545
|
-
var
|
|
2605
|
+
var import_sdk14 = require("@hook-sdk/sdk");
|
|
2546
2606
|
function useAuth() {
|
|
2547
|
-
const { user, authStatus, auth } = (0,
|
|
2607
|
+
const { user, authStatus, auth } = (0, import_sdk14.useHook)();
|
|
2548
2608
|
return {
|
|
2549
2609
|
user,
|
|
2550
2610
|
authStatus,
|
|
@@ -2553,23 +2613,23 @@ function useAuth() {
|
|
|
2553
2613
|
}
|
|
2554
2614
|
|
|
2555
2615
|
// src/hooks/useSubscription.ts
|
|
2556
|
-
var
|
|
2616
|
+
var import_sdk15 = require("@hook-sdk/sdk");
|
|
2557
2617
|
function useSubscription() {
|
|
2558
|
-
const { subscription } = (0,
|
|
2618
|
+
const { subscription } = (0, import_sdk15.useHook)();
|
|
2559
2619
|
return {
|
|
2560
2620
|
status: subscription.status()
|
|
2561
2621
|
};
|
|
2562
2622
|
}
|
|
2563
2623
|
|
|
2564
2624
|
// src/hooks/useReminders.ts
|
|
2565
|
-
var
|
|
2566
|
-
var
|
|
2625
|
+
var import_react19 = require("react");
|
|
2626
|
+
var import_sdk16 = require("@hook-sdk/sdk");
|
|
2567
2627
|
function useReminders() {
|
|
2568
|
-
const { push } = (0,
|
|
2628
|
+
const { push } = (0, import_sdk16.useHook)();
|
|
2569
2629
|
const r = push.reminders;
|
|
2570
|
-
const [reminders, setReminders] = (0,
|
|
2571
|
-
const [loading, setLoading] = (0,
|
|
2572
|
-
const reload = (0,
|
|
2630
|
+
const [reminders, setReminders] = (0, import_react19.useState)([]);
|
|
2631
|
+
const [loading, setLoading] = (0, import_react19.useState)(true);
|
|
2632
|
+
const reload = (0, import_react19.useCallback)(async () => {
|
|
2573
2633
|
setLoading(true);
|
|
2574
2634
|
try {
|
|
2575
2635
|
const next = await r.list();
|
|
@@ -2578,38 +2638,38 @@ function useReminders() {
|
|
|
2578
2638
|
setLoading(false);
|
|
2579
2639
|
}
|
|
2580
2640
|
}, [r]);
|
|
2581
|
-
(0,
|
|
2641
|
+
(0, import_react19.useEffect)(() => {
|
|
2582
2642
|
void reload();
|
|
2583
2643
|
}, [reload]);
|
|
2584
|
-
const setReminder = (0,
|
|
2644
|
+
const setReminder = (0, import_react19.useCallback)(async (input) => {
|
|
2585
2645
|
await r.set(input);
|
|
2586
2646
|
await reload();
|
|
2587
2647
|
}, [r, reload]);
|
|
2588
|
-
const deleteReminder = (0,
|
|
2648
|
+
const deleteReminder = (0, import_react19.useCallback)(async (slot) => {
|
|
2589
2649
|
await r.delete(slot);
|
|
2590
2650
|
await reload();
|
|
2591
2651
|
}, [r, reload]);
|
|
2592
|
-
const schedule = (0,
|
|
2652
|
+
const schedule = (0, import_react19.useCallback)(async (items) => {
|
|
2593
2653
|
return r.schedule(items);
|
|
2594
2654
|
}, [r]);
|
|
2595
|
-
const setFallbacks = (0,
|
|
2655
|
+
const setFallbacks = (0, import_react19.useCallback)(async (items) => {
|
|
2596
2656
|
return r.setFallbacks(items);
|
|
2597
2657
|
}, [r]);
|
|
2598
2658
|
return { reminders, loading, setReminder, deleteReminder, schedule, setFallbacks };
|
|
2599
2659
|
}
|
|
2600
2660
|
|
|
2601
2661
|
// src/hooks/useToast.ts
|
|
2602
|
-
var
|
|
2662
|
+
var import_react20 = require("react");
|
|
2603
2663
|
function useToast() {
|
|
2604
|
-
const [items, setItems] = (0,
|
|
2605
|
-
const show = (0,
|
|
2664
|
+
const [items, setItems] = (0, import_react20.useState)([]);
|
|
2665
|
+
const show = (0, import_react20.useCallback)((message, kind = "info") => {
|
|
2606
2666
|
const id = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
2607
2667
|
setItems((prev) => [...prev, { id, message, kind }]);
|
|
2608
2668
|
setTimeout(() => {
|
|
2609
2669
|
setItems((prev) => prev.filter((t) => t.id !== id));
|
|
2610
2670
|
}, 4e3);
|
|
2611
2671
|
}, []);
|
|
2612
|
-
const dismiss = (0,
|
|
2672
|
+
const dismiss = (0, import_react20.useCallback)((id) => {
|
|
2613
2673
|
setItems((prev) => prev.filter((t) => t.id !== id));
|
|
2614
2674
|
}, []);
|
|
2615
2675
|
return { items, show, dismiss };
|
|
@@ -2617,20 +2677,20 @@ function useToast() {
|
|
|
2617
2677
|
|
|
2618
2678
|
// src/RouteBoundary.tsx
|
|
2619
2679
|
var import_react_router_dom3 = require("react-router-dom");
|
|
2620
|
-
var
|
|
2680
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2621
2681
|
function RouteBoundary({ children }) {
|
|
2622
|
-
return /* @__PURE__ */ (0,
|
|
2682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_react_router_dom3.Routes, { children: [
|
|
2623
2683
|
children,
|
|
2624
|
-
/* @__PURE__ */ (0,
|
|
2684
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react_router_dom3.Route, { path: "*", element: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DefaultNotFound, {}) })
|
|
2625
2685
|
] });
|
|
2626
2686
|
}
|
|
2627
2687
|
function DefaultNotFound() {
|
|
2628
|
-
return /* @__PURE__ */ (0,
|
|
2688
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { role: "alert", children: "P\xE1gina n\xE3o encontrada" });
|
|
2629
2689
|
}
|
|
2630
2690
|
|
|
2631
2691
|
// src/PreAuthShell.tsx
|
|
2632
2692
|
var import_react_router_dom4 = require("react-router-dom");
|
|
2633
|
-
var
|
|
2693
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2634
2694
|
function PreAuthShell({
|
|
2635
2695
|
basename,
|
|
2636
2696
|
testRouter,
|
|
@@ -2638,20 +2698,20 @@ function PreAuthShell({
|
|
|
2638
2698
|
children
|
|
2639
2699
|
}) {
|
|
2640
2700
|
if (testRouter === "memory") {
|
|
2641
|
-
return /* @__PURE__ */ (0,
|
|
2701
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_router_dom4.MemoryRouter, { basename, initialEntries: testInitialEntries, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_router_dom4.Routes, { children }) });
|
|
2642
2702
|
}
|
|
2643
|
-
return /* @__PURE__ */ (0,
|
|
2703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_router_dom4.BrowserRouter, { basename, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_router_dom4.Routes, { children }) });
|
|
2644
2704
|
}
|
|
2645
2705
|
|
|
2646
2706
|
// src/OnboardingFlow.tsx
|
|
2647
|
-
var
|
|
2648
|
-
var
|
|
2707
|
+
var import_react22 = require("react");
|
|
2708
|
+
var import_sdk17 = require("@hook-sdk/sdk");
|
|
2649
2709
|
|
|
2650
2710
|
// src/hooks/useOnboardingStep.ts
|
|
2651
|
-
var
|
|
2652
|
-
var OnboardingStepContext = (0,
|
|
2711
|
+
var import_react21 = require("react");
|
|
2712
|
+
var OnboardingStepContext = (0, import_react21.createContext)(null);
|
|
2653
2713
|
function useOnboardingStep() {
|
|
2654
|
-
const ctx = (0,
|
|
2714
|
+
const ctx = (0, import_react21.useContext)(OnboardingStepContext);
|
|
2655
2715
|
if (!ctx) {
|
|
2656
2716
|
throw new Error(
|
|
2657
2717
|
"[hook-template] useOnboardingStep must be used inside <OnboardingFlow>. (G75)"
|
|
@@ -2661,7 +2721,7 @@ function useOnboardingStep() {
|
|
|
2661
2721
|
}
|
|
2662
2722
|
|
|
2663
2723
|
// src/OnboardingFlow.tsx
|
|
2664
|
-
var
|
|
2724
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2665
2725
|
var isFilled = (v) => v != null && v !== "";
|
|
2666
2726
|
var CURRENT_STEP_FIELD = "currentStep";
|
|
2667
2727
|
function readPersistedStepIdx(draft) {
|
|
@@ -2674,12 +2734,12 @@ function OnboardingFlow({
|
|
|
2674
2734
|
onComplete,
|
|
2675
2735
|
persistKey
|
|
2676
2736
|
}) {
|
|
2677
|
-
const [draft, setDraft, status] = (0,
|
|
2678
|
-
const draftRef = (0,
|
|
2737
|
+
const [draft, setDraft, status] = (0, import_sdk17.usePersistedState)(persistKey, {});
|
|
2738
|
+
const draftRef = (0, import_react22.useRef)(draft);
|
|
2679
2739
|
draftRef.current = draft;
|
|
2680
2740
|
const idx = readPersistedStepIdx(draft);
|
|
2681
2741
|
const clampedIdx = Math.min(Math.max(idx, 0), Math.max(steps.length - 1, 0));
|
|
2682
|
-
const setIdx = (0,
|
|
2742
|
+
const setIdx = (0, import_react22.useCallback)(
|
|
2683
2743
|
(n) => {
|
|
2684
2744
|
setDraft((prev) => {
|
|
2685
2745
|
const prevIdx = readPersistedStepIdx(prev);
|
|
@@ -2689,7 +2749,7 @@ function OnboardingFlow({
|
|
|
2689
2749
|
},
|
|
2690
2750
|
[setDraft]
|
|
2691
2751
|
);
|
|
2692
|
-
const setValue = (0,
|
|
2752
|
+
const setValue = (0, import_react22.useCallback)(
|
|
2693
2753
|
(patch) => {
|
|
2694
2754
|
draftRef.current = { ...draftRef.current, ...patch };
|
|
2695
2755
|
setDraft((prev) => ({ ...prev, ...patch }));
|
|
@@ -2697,11 +2757,11 @@ function OnboardingFlow({
|
|
|
2697
2757
|
[setDraft]
|
|
2698
2758
|
);
|
|
2699
2759
|
const step = steps[clampedIdx];
|
|
2700
|
-
const valid = (0,
|
|
2760
|
+
const valid = (0, import_react22.useMemo)(
|
|
2701
2761
|
() => step ? (step.validates ?? []).every((field) => isFilled(draft[field])) : false,
|
|
2702
2762
|
[draft, step]
|
|
2703
2763
|
);
|
|
2704
|
-
const next = (0,
|
|
2764
|
+
const next = (0, import_react22.useCallback)(() => {
|
|
2705
2765
|
if (!step) return;
|
|
2706
2766
|
const current = draftRef.current;
|
|
2707
2767
|
const validNow = (step.validates ?? []).every((field) => isFilled(current[field]));
|
|
@@ -2712,8 +2772,8 @@ function OnboardingFlow({
|
|
|
2712
2772
|
setIdx(clampedIdx + 1);
|
|
2713
2773
|
}
|
|
2714
2774
|
}, [clampedIdx, onComplete, step, steps.length, setIdx]);
|
|
2715
|
-
const prevStep = (0,
|
|
2716
|
-
const ctx = (0,
|
|
2775
|
+
const prevStep = (0, import_react22.useCallback)(() => setIdx((i) => Math.max(0, i - 1)), [setIdx]);
|
|
2776
|
+
const ctx = (0, import_react22.useMemo)(
|
|
2717
2777
|
() => ({
|
|
2718
2778
|
stepIndex: clampedIdx,
|
|
2719
2779
|
totalSteps: steps.length,
|
|
@@ -2739,7 +2799,7 @@ function OnboardingFlow({
|
|
|
2739
2799
|
`[hook-template] OnboardingFlow: missing screen component for step '${step.id}' (expected key '${step.screen}' in screens prop)`
|
|
2740
2800
|
);
|
|
2741
2801
|
}
|
|
2742
|
-
return /* @__PURE__ */ (0,
|
|
2802
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(OnboardingStepContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Screen, {}) });
|
|
2743
2803
|
}
|
|
2744
2804
|
|
|
2745
2805
|
// src/hooks/useFeature.ts
|