@stevederico/skateboard-ui 5.6.0 → 5.8.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/CHANGELOG.md
CHANGED
package/dist/components/Sheet.js
CHANGED
|
@@ -44,6 +44,6 @@ const MySheet = forwardRef(function MySheet(props, ref) {
|
|
|
44
44
|
setIsOpen(open);
|
|
45
45
|
if (!open)
|
|
46
46
|
onUserClose?.();
|
|
47
|
-
}, children: _jsxs(DrawerContent, { style: { minHeight }, children: [_jsx(DrawerHeader, { children: _jsx(DrawerTitle, { children: title }) }), _jsx("div", { className: "px-4 pb-4", children: children })] }) }));
|
|
47
|
+
}, children: _jsxs(DrawerContent, { style: { minHeight }, children: [_jsx(DrawerHeader, { children: _jsx(DrawerTitle, { children: title }) }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pb-4", children: children })] }) }));
|
|
48
48
|
});
|
|
49
49
|
export default MySheet;
|
|
@@ -10,6 +10,24 @@ import ConstantsIcon from '../core/constantsIcon.js';
|
|
|
10
10
|
import { Sparkles } from 'lucide-react';
|
|
11
11
|
import { getState } from "../core/Context.js";
|
|
12
12
|
import { getBackendURL, useSafeNavigate, getAppKey } from '../core/Utilities.js';
|
|
13
|
+
let turnstileScript = null;
|
|
14
|
+
/** Load Cloudflare's Turnstile script once. */
|
|
15
|
+
function loadTurnstile() {
|
|
16
|
+
if (!turnstileScript) {
|
|
17
|
+
turnstileScript = new Promise((resolve, reject) => {
|
|
18
|
+
const script = document.createElement('script');
|
|
19
|
+
script.src = 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit';
|
|
20
|
+
script.async = true;
|
|
21
|
+
script.onload = () => resolve();
|
|
22
|
+
script.onerror = () => {
|
|
23
|
+
turnstileScript = null;
|
|
24
|
+
reject(new Error('Turnstile failed to load'));
|
|
25
|
+
};
|
|
26
|
+
document.head.appendChild(script);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return turnstileScript;
|
|
30
|
+
}
|
|
13
31
|
export default function SignUpView({ className, embedded = false, onSuccess, onSwitchMode, ...props }) {
|
|
14
32
|
const { state, dispatch } = getState();
|
|
15
33
|
const constants = state.constants;
|
|
@@ -20,6 +38,42 @@ export default function SignUpView({ className, embedded = false, onSuccess, onS
|
|
|
20
38
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
21
39
|
const navigate = useSafeNavigate();
|
|
22
40
|
const nameInputRef = useRef(null);
|
|
41
|
+
const turnstileRef = useRef(null);
|
|
42
|
+
const turnstileIdRef = useRef(null);
|
|
43
|
+
const [turnstileToken, setTurnstileToken] = useState('');
|
|
44
|
+
// Optional Cloudflare Turnstile: the backend hands out a site key from
|
|
45
|
+
// GET /signup/options. No key, or no endpoint, means no widget.
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
let cancelled = false;
|
|
48
|
+
(async () => {
|
|
49
|
+
try {
|
|
50
|
+
const res = await fetch(`${getBackendURL()}/signup/options`, { credentials: 'include' });
|
|
51
|
+
if (!res.ok)
|
|
52
|
+
return;
|
|
53
|
+
const { turnstileSiteKey } = (await res.json());
|
|
54
|
+
if (!turnstileSiteKey || cancelled)
|
|
55
|
+
return;
|
|
56
|
+
await loadTurnstile();
|
|
57
|
+
const container = turnstileRef.current;
|
|
58
|
+
const api = window.turnstile;
|
|
59
|
+
if (!container || !api || cancelled)
|
|
60
|
+
return;
|
|
61
|
+
turnstileIdRef.current = api.render(container, {
|
|
62
|
+
sitekey: turnstileSiteKey,
|
|
63
|
+
appearance: 'interaction-only',
|
|
64
|
+
callback: (token) => setTurnstileToken(token),
|
|
65
|
+
'expired-callback': () => setTurnstileToken(''),
|
|
66
|
+
'error-callback': () => setTurnstileToken(''),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
/* Turnstile is optional; sign-up works without it. */
|
|
71
|
+
}
|
|
72
|
+
})();
|
|
73
|
+
return () => {
|
|
74
|
+
cancelled = true;
|
|
75
|
+
};
|
|
76
|
+
}, []);
|
|
23
77
|
// Focus the first input on mount
|
|
24
78
|
useEffect(() => {
|
|
25
79
|
if (!name && nameInputRef.current) {
|
|
@@ -45,7 +99,7 @@ export default function SignUpView({ className, embedded = false, onSuccess, onS
|
|
|
45
99
|
method: 'POST',
|
|
46
100
|
credentials: 'include',
|
|
47
101
|
headers: { 'Content-Type': 'application/json' },
|
|
48
|
-
body: JSON.stringify({ email, password, name })
|
|
102
|
+
body: JSON.stringify({ email, password, name, ...(turnstileToken ? { turnstileToken } : {}) })
|
|
49
103
|
});
|
|
50
104
|
if (response.ok) {
|
|
51
105
|
const data = await response.json();
|
|
@@ -64,7 +118,13 @@ export default function SignUpView({ className, embedded = false, onSuccess, onS
|
|
|
64
118
|
}
|
|
65
119
|
}
|
|
66
120
|
else {
|
|
67
|
-
|
|
121
|
+
const failure = (await response.json().catch(() => null));
|
|
122
|
+
setErrorMessage(failure?.error || 'Invalid Credentials');
|
|
123
|
+
const api = window.turnstile;
|
|
124
|
+
if (api && turnstileIdRef.current) {
|
|
125
|
+
api.reset(turnstileIdRef.current);
|
|
126
|
+
setTurnstileToken('');
|
|
127
|
+
}
|
|
68
128
|
}
|
|
69
129
|
}
|
|
70
130
|
catch (error) {
|
|
@@ -84,7 +144,7 @@ export default function SignUpView({ className, embedded = false, onSuccess, onS
|
|
|
84
144
|
} })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "password", children: "Password" }), _jsx(Input, { id: "password", type: "password", placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022", autoComplete: "new-password", required: true, minLength: 6, maxLength: 72, value: password, onChange: (e) => {
|
|
85
145
|
setPassword(e.target.value);
|
|
86
146
|
setErrorMessage('');
|
|
87
|
-
} }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Minimum 6 characters" })] }), _jsx(Button, { type: "submit", variant: "gradient", size: "cta", className: "w-full", disabled: isSubmitting, children: _jsxs("span", { className: "relative z-20 flex items-center justify-center gap-2 drop-shadow-sm", children: [_jsx(Sparkles, { size: 16, color: "currentColor", strokeWidth: 2, className: "animate-pulse" }), isSubmitting ? "Signing up..." : "Sign Up"] }) }), _jsxs("div", { className: "text-center text-sm", children: [_jsx("span", { className: "text-muted-foreground", children: "Already have an account?" }), " ", _jsx(Button, { variant: "link", className: "p-0 h-auto", onClick: (e) => { e.preventDefault(); embedded && onSwitchMode ? onSwitchMode() : navigate('/signin'); }, children: "Sign In" })] })] }), _jsxs("div", { className: "mt-4 text-center text-xs text-muted-foreground", children: ["By registering you agree to our", " ", _jsx("a", { href: "/terms", className: "underline underline-offset-4 hover:text-foreground", children: "Terms of Service" }), ",", " ", _jsx("a", { href: "/eula", className: "underline underline-offset-4 hover:text-foreground", children: "EULA" }), ",", " ", _jsx("a", { href: "/privacy", className: "underline underline-offset-4 hover:text-foreground", children: "Privacy Policy" })] })] }));
|
|
147
|
+
} }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Minimum 6 characters" })] }), _jsx("div", { ref: turnstileRef }), _jsx(Button, { type: "submit", variant: "gradient", size: "cta", className: "w-full", disabled: isSubmitting, children: _jsxs("span", { className: "relative z-20 flex items-center justify-center gap-2 drop-shadow-sm", children: [_jsx(Sparkles, { size: 16, color: "currentColor", strokeWidth: 2, className: "animate-pulse" }), isSubmitting ? "Signing up..." : "Sign Up"] }) }), _jsxs("div", { className: "text-center text-sm", children: [_jsx("span", { className: "text-muted-foreground", children: "Already have an account?" }), " ", _jsx(Button, { variant: "link", className: "p-0 h-auto", onClick: (e) => { e.preventDefault(); embedded && onSwitchMode ? onSwitchMode() : navigate('/signin'); }, children: "Sign In" })] })] }), _jsxs("div", { className: "mt-4 text-center text-xs text-muted-foreground", children: ["By registering you agree to our", " ", _jsx("a", { href: "/terms", className: "underline underline-offset-4 hover:text-foreground", children: "Terms of Service" }), ",", " ", _jsx("a", { href: "/eula", className: "underline underline-offset-4 hover:text-foreground", children: "EULA" }), ",", " ", _jsx("a", { href: "/privacy", className: "underline underline-offset-4 hover:text-foreground", children: "Privacy Policy" })] })] }));
|
|
88
148
|
if (embedded) {
|
|
89
149
|
return formContent;
|
|
90
150
|
}
|