@slyxup/ui 0.1.0 → 0.2.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 +17 -0
- package/README.md +105 -0
- package/dist/components/EmailVerification/EmailVerification.d.ts +9 -0
- package/dist/components/EmailVerification/EmailVerification.d.ts.map +1 -0
- package/dist/components/EmailVerification/EmailVerification.js +72 -0
- package/dist/components/EmailVerification/EmailVerification.js.map +1 -0
- package/dist/components/ForgotPassword/ForgotPassword.d.ts +8 -0
- package/dist/components/ForgotPassword/ForgotPassword.d.ts.map +1 -0
- package/dist/components/ForgotPassword/ForgotPassword.js +43 -0
- package/dist/components/ForgotPassword/ForgotPassword.js.map +1 -0
- package/dist/components/ResetPassword/ResetPassword.d.ts +9 -0
- package/dist/components/ResetPassword/ResetPassword.d.ts.map +1 -0
- package/dist/components/ResetPassword/ResetPassword.js +50 -0
- package/dist/components/ResetPassword/ResetPassword.js.map +1 -0
- package/dist/components/SignIn/SignIn.d.ts +11 -0
- package/dist/components/SignIn/SignIn.d.ts.map +1 -0
- package/dist/components/SignIn/SignIn.js +42 -0
- package/dist/components/SignIn/SignIn.js.map +1 -0
- package/dist/components/SignUp/SignUp.d.ts +8 -0
- package/dist/components/SignUp/SignUp.d.ts.map +1 -0
- package/dist/components/SignUp/SignUp.js +43 -0
- package/dist/components/SignUp/SignUp.js.map +1 -0
- package/dist/components/SocialButtons/SocialButtons.d.ts +9 -0
- package/dist/components/SocialButtons/SocialButtons.d.ts.map +1 -0
- package/dist/components/SocialButtons/SocialButtons.js +16 -0
- package/dist/components/SocialButtons/SocialButtons.js.map +1 -0
- package/dist/components/UserButton/UserButton.d.ts +3 -0
- package/dist/components/UserButton/UserButton.d.ts.map +1 -0
- package/dist/components/UserButton/UserButton.js +43 -0
- package/dist/components/UserButton/UserButton.js.map +1 -0
- package/dist/components/UserProfile/UserProfile.d.ts +3 -0
- package/dist/components/UserProfile/UserProfile.d.ts.map +1 -0
- package/dist/components/UserProfile/UserProfile.js +38 -0
- package/dist/components/UserProfile/UserProfile.js.map +1 -0
- package/dist/icons.d.ts +6 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +15 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.d.ts +8 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +198 -0
- package/dist/styles.js.map +1 -0
- package/package.json +30 -2
- package/src/components/EmailVerification/EmailVerification.tsx +180 -0
- package/src/components/ForgotPassword/ForgotPassword.tsx +122 -0
- package/src/components/ResetPassword/ResetPassword.tsx +120 -0
- package/src/components/SignIn/SignIn.tsx +143 -0
- package/src/components/SignUp/SignUp.tsx +156 -0
- package/src/components/SocialButtons/SocialButtons.tsx +39 -0
- package/src/components/UserButton/UserButton.tsx +89 -0
- package/src/components/UserProfile/UserProfile.tsx +93 -0
- package/src/icons.tsx +71 -0
- package/src/index.ts +37 -1
- package/src/styles.ts +199 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @slyxup/ui
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`7cf24ff`](https://github.com/slyxup/stack/commit/7cf24ffe37fe6f2bca41fdc0281618c2db02b3ae) - Full V1 SDKs: SlyxupClient with cookie jar, React provider + hooks, Next.js server helpers/middleware, themed UI components, slyxup CLI
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`44da26b`](https://github.com/slyxup/stack/commit/44da26bd8f952b6fce4b67f75ddb0ef041a984ac) - ci: verify all packages CI/CD — little change in every package + auth/stack/billing
|
|
12
|
+
|
|
13
|
+
- [`fe4f8bb`](https://github.com/slyxup/stack/commit/fe4f8bb4ab412a58303f59921548d3625b0675c9) - ci: second verify all — 14:55
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`44da26b`](https://github.com/slyxup/stack/commit/44da26bd8f952b6fce4b67f75ddb0ef041a984ac), [`fe4f8bb`](https://github.com/slyxup/stack/commit/fe4f8bb4ab412a58303f59921548d3625b0675c9), [`7cf24ff`](https://github.com/slyxup/stack/commit/7cf24ffe37fe6f2bca41fdc0281618c2db02b3ae)]:
|
|
16
|
+
- @slyxup/core@0.2.0
|
|
17
|
+
- @slyxup/react@0.2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# @slyxup/ui
|
|
2
|
+
|
|
3
|
+
Prebuilt, themeable auth components — sign-in cards, user button, password flows. Built on [`@slyxup/react`](../react). **Zero CSS dependencies** — styles are self-contained and injected once.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @slyxup/ui @slyxup/react @slyxup/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> Peer: `react ^18 || ^19`
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
Inject the stylesheet once at your app root:
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { SlyxUpProvider } from '@slyxup/react';
|
|
19
|
+
import { SlyxUpStyles } from '@slyxup/ui';
|
|
20
|
+
|
|
21
|
+
<SlyxUpProvider publishableKey="pk_test_xxx">
|
|
22
|
+
<SlyxUpStyles />
|
|
23
|
+
<App />
|
|
24
|
+
</SlyxUpProvider>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
(Components also auto-inject on first mount if you skip this.)
|
|
28
|
+
|
|
29
|
+
## Components
|
|
30
|
+
|
|
31
|
+
### `<SignIn />` / `<SignUp />`
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { SignIn, SignUp } from '@slyxup/ui';
|
|
35
|
+
|
|
36
|
+
<SignIn
|
|
37
|
+
social // show Google/GitHub buttons (default true)
|
|
38
|
+
onSuccess={() => router.push('/dashboard')}
|
|
39
|
+
onSignUpClick={() => setMode('sign-up')}
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
<SignUp onSignInClick={() => setMode('sign-in')} />
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### `<UserButton />` — avatar + dropdown
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { UserButton } from '@slyxup/ui';
|
|
49
|
+
|
|
50
|
+
<header>
|
|
51
|
+
<UserButton /> {/* gradient initials avatar → menu: profile, sign out */}
|
|
52
|
+
</header>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Renders nothing until loaded; shows initials or avatar image.
|
|
56
|
+
|
|
57
|
+
### `<UserProfile />`
|
|
58
|
+
|
|
59
|
+
Edit first/last name and avatar URL with inline save confirmation.
|
|
60
|
+
|
|
61
|
+
### Password flows
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
<ForgotPassword onBackToSignIn={...} />
|
|
65
|
+
<ResetPassword token={searchParams.token} onSuccess={...} />
|
|
66
|
+
<EmailVerification token={searchParams.token} />
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`ForgotPassword` always shows a neutral success state (never reveals whether an account exists). `EmailVerification` auto-verifies from the emailed token and offers a resend form otherwise.
|
|
70
|
+
|
|
71
|
+
### `<SocialButtons />`
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<SocialButtons providers={['google', 'github']} basePath="/v1/oauth" />
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Redirects to the hosted OAuth flow.
|
|
78
|
+
|
|
79
|
+
## Theming
|
|
80
|
+
|
|
81
|
+
Override CSS variables on any wrapper — light/dark is automatic via `prefers-color-scheme`, force dark with `slyxup-dark`, force light with `slyxup-light`.
|
|
82
|
+
|
|
83
|
+
```css
|
|
84
|
+
.slyxup-root {
|
|
85
|
+
--slx-accent: #e8562a; /* your brand color */
|
|
86
|
+
--slx-radius: 16px;
|
|
87
|
+
--slx-font: "Inter", sans-serif;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
| Variable | Default (light) |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `--slx-accent` | `#5b5bd6` |
|
|
94
|
+
| `--slx-bg` | `#ffffff` |
|
|
95
|
+
| `--slx-ink` | `#16161d` |
|
|
96
|
+
| `--slx-muted` | `#6f6f7b` |
|
|
97
|
+
| `--slx-border` | `#e6e6ec` |
|
|
98
|
+
| `--slx-danger` | `#d64550` |
|
|
99
|
+
| `--slx-radius` | `12px` |
|
|
100
|
+
|
|
101
|
+
Accessibility built in: labeled fields, visible focus rings, `prefers-reduced-motion` respected, semantic buttons throughout.
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
MIT © [SlyxUp](https://github.com/slyxup/stack)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface EmailVerificationProps {
|
|
2
|
+
/** Verification token (from email link ?token=...). If absent, shows resend form. */
|
|
3
|
+
token?: string;
|
|
4
|
+
apiUrl?: string;
|
|
5
|
+
onSuccess?: () => void;
|
|
6
|
+
}
|
|
7
|
+
/** Verify an email with the emailed token, or request a new link. */
|
|
8
|
+
export declare function EmailVerification({ token, apiUrl, onSuccess, }: EmailVerificationProps): import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=EmailVerification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailVerification.d.ts","sourceRoot":"","sources":["../../../src/components/EmailVerification/EmailVerification.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,sBAAsB;IACrC,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,qEAAqE;AACrE,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,MAAM,EACN,SAAS,GACV,EAAE,sBAAsB,+BAoKxB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { CheckIcon, KeyholeMark } from '../../icons';
|
|
4
|
+
/** Verify an email with the emailed token, or request a new link. */
|
|
5
|
+
export function EmailVerification({ token, apiUrl, onSuccess, }) {
|
|
6
|
+
const [status, setStatus] = useState(token ? 'verifying' : 'resend');
|
|
7
|
+
const [message, setMessage] = useState('');
|
|
8
|
+
const [email, setEmail] = useState('');
|
|
9
|
+
const [busy, setBusy] = useState(false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (!token)
|
|
12
|
+
return;
|
|
13
|
+
let cancelled = false;
|
|
14
|
+
(async () => {
|
|
15
|
+
try {
|
|
16
|
+
const base = (apiUrl ??
|
|
17
|
+
process.env.NEXT_PUBLIC_SLYXUP_API_URL ??
|
|
18
|
+
'https://auth.slyxup.online').replace(/\/$/, '');
|
|
19
|
+
const res = await fetch(`${base}/v1/verification/verify`, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers: { 'Content-Type': 'application/json' },
|
|
22
|
+
body: JSON.stringify({ token }),
|
|
23
|
+
});
|
|
24
|
+
if (cancelled)
|
|
25
|
+
return;
|
|
26
|
+
if (res.ok) {
|
|
27
|
+
setStatus('success');
|
|
28
|
+
setTimeout(() => onSuccess?.(), 1800);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const data = await res
|
|
32
|
+
.json()
|
|
33
|
+
.catch(() => ({ error: 'Invalid or expired link' }));
|
|
34
|
+
setMessage(data.error ?? 'Invalid or expired link');
|
|
35
|
+
setStatus('error');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
if (!cancelled) {
|
|
40
|
+
setMessage('Network problem. Try again.');
|
|
41
|
+
setStatus('error');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
})();
|
|
45
|
+
return () => {
|
|
46
|
+
cancelled = true;
|
|
47
|
+
};
|
|
48
|
+
}, [token, apiUrl, onSuccess]);
|
|
49
|
+
async function resend(e) {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
setBusy(true);
|
|
52
|
+
try {
|
|
53
|
+
const base = (apiUrl ??
|
|
54
|
+
process.env.NEXT_PUBLIC_SLYXUP_API_URL ??
|
|
55
|
+
'https://auth.slyxup.online').replace(/\/$/, '');
|
|
56
|
+
await fetch(`${base}/v1/verification/resend`, {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
headers: { 'Content-Type': 'application/json' },
|
|
59
|
+
body: JSON.stringify({ email }),
|
|
60
|
+
});
|
|
61
|
+
setMessage('If that account exists, a new verification link is on its way.');
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
setMessage('Network problem. Try again.');
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
setBusy(false);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return (_jsxs("div", { className: "slx-card", children: [_jsx("div", { className: "slx-mark", children: _jsx(KeyholeMark, {}) }), status === 'verifying' && (_jsxs(_Fragment, { children: [_jsx("h1", { className: "slx-title", children: "Verifying your email\u2026" }), _jsx("p", { className: "slx-subtitle", children: "One moment while we confirm." })] })), status === 'success' && (_jsxs(_Fragment, { children: [_jsx("div", { className: "slx-success-icon", children: _jsx(CheckIcon, {}) }), _jsx("h1", { className: "slx-title", style: { textAlign: 'center' }, children: "Email verified" }), _jsx("p", { className: "slx-subtitle", style: { textAlign: 'center' }, children: "You're all set. Redirecting\u2026" })] })), status === 'error' && (_jsxs(_Fragment, { children: [_jsx("h1", { className: "slx-title", children: "Link didn't work" }), message && (_jsx("p", { className: "slx-error-text", role: "alert", children: message })), _jsx("p", { className: "slx-subtitle", children: "Request a fresh link below." }), _jsxs("form", { onSubmit: resend, children: [_jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-verify-email", children: "Email" }), _jsx("input", { id: "slx-verify-email", className: "slx-input", type: "email", placeholder: "you@example.com", value: email, onChange: (e) => setEmail(e.target.value), required: true })] }), _jsxs("button", { className: "slx-btn", type: "submit", disabled: busy, children: [busy && _jsx("span", { className: "slx-spinner", "aria-hidden": "true" }), busy ? 'Sending…' : 'Resend verification email'] })] })] })), status === 'resend' && (_jsxs(_Fragment, { children: [_jsx("h1", { className: "slx-title", children: "Verify your email" }), _jsx("p", { className: "slx-subtitle", children: "Enter your email and we'll send a verification link." }), message && (_jsx("p", { className: "slx-hint", style: { marginBottom: 12 }, children: message })), _jsxs("form", { onSubmit: resend, children: [_jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-verify-email2", children: "Email" }), _jsx("input", { id: "slx-verify-email2", className: "slx-input", type: "email", placeholder: "you@example.com", value: email, onChange: (e) => setEmail(e.target.value), required: true })] }), _jsxs("button", { className: "slx-btn", type: "submit", disabled: busy, children: [busy && _jsx("span", { className: "slx-spinner", "aria-hidden": "true" }), busy ? 'Sending…' : 'Send verification link'] })] })] }))] }));
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=EmailVerification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailVerification.js","sourceRoot":"","sources":["../../../src/components/EmailVerification/EmailVerification.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AASrD,qEAAqE;AACrE,MAAM,UAAU,iBAAiB,CAAC,EAChC,KAAK,EACL,MAAM,EACN,SAAS,GACc;IACvB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAElC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,CAAC,OAAO,EA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AAS,EAAC,UAAU,EAAC,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,YAChD,OAAO,GACN,CACL,EACD,gBAAM,QAAQ,EAAE,MAAM,aACpB,eAAK,SAAS,EAAC,WAAW,aACxB,gBAAO,SAAS,EAAC,WAAW,EAAC,OAAO,EAAC,mBAAmB,sBAEhD,EACR,gBACE,EAAE,EAAC,mBAAmB,EACtB,SAAS,EAAC,WAAW,EACrB,IAAI,EAAC,OAAO,EACZ,WAAW,EAAC,iBAAiB,EAC7B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACzC,QAAQ,SACR,IACE,EACN,kBAAQ,SAAS,EAAC,SAAS,EAAC,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,IAAI,aACrD,IAAI,IAAI,eAAM,SAAS,EAAC,aAAa,iBAAa,MAAM,GAAG,EAC3D,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,wBAAwB,IACtC,IACJ,IACN,CACJ,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ForgotPasswordProps {
|
|
2
|
+
apiUrl?: string;
|
|
3
|
+
onSuccess?: () => void;
|
|
4
|
+
onBackToSignIn?: () => void;
|
|
5
|
+
}
|
|
6
|
+
/** Request a password-reset email. */
|
|
7
|
+
export declare function ForgotPassword({ apiUrl, onSuccess, onBackToSignIn, }: ForgotPasswordProps): import("react").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=ForgotPassword.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ForgotPassword.d.ts","sourceRoot":"","sources":["../../../src/components/ForgotPassword/ForgotPassword.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,sCAAsC;AACtC,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,SAAS,EACT,cAAc,GACf,EAAE,mBAAmB,+BA0GrB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SlyxupClient } from '@slyxup/core';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { CheckIcon, KeyholeMark } from '../../icons';
|
|
5
|
+
/** Request a password-reset email. */
|
|
6
|
+
export function ForgotPassword({ apiUrl, onSuccess, onBackToSignIn, }) {
|
|
7
|
+
const [email, setEmail] = useState('');
|
|
8
|
+
const [sent, setSent] = useState(false);
|
|
9
|
+
const [busy, setBusy] = useState(false);
|
|
10
|
+
const [error, setError] = useState(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (error) {
|
|
13
|
+
const t = setTimeout(() => setError(null), 4000);
|
|
14
|
+
return () => clearTimeout(t);
|
|
15
|
+
}
|
|
16
|
+
}, [error]);
|
|
17
|
+
async function onSubmit(e) {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
setBusy(true);
|
|
20
|
+
setError(null);
|
|
21
|
+
try {
|
|
22
|
+
await fetch(`${(apiUrl ?? process.env.NEXT_PUBLIC_SLYXUP_API_URL ?? 'https://auth.slyxup.online').replace(/\/$/, '')}/v1/verification/password/forgot`, {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: { 'Content-Type': 'application/json' },
|
|
25
|
+
body: JSON.stringify({ email }),
|
|
26
|
+
});
|
|
27
|
+
setSent(true); // always success — never reveal account existence
|
|
28
|
+
onSuccess?.();
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
setError('Network problem. Check your connection and try again.');
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
setBusy(false);
|
|
35
|
+
}
|
|
36
|
+
void SlyxupClient; // tree-shake guard
|
|
37
|
+
}
|
|
38
|
+
if (sent) {
|
|
39
|
+
return (_jsxs("div", { className: "slx-card", children: [_jsx("div", { className: "slx-success-icon", children: _jsx(CheckIcon, {}) }), _jsx("h1", { className: "slx-title", style: { textAlign: 'center' }, children: "Check your email" }), _jsxs("p", { className: "slx-subtitle", style: { textAlign: 'center' }, children: ["If an account exists for ", email, ", a reset link is on its way."] }), onBackToSignIn && (_jsx("p", { className: "slx-footer", children: _jsx("button", { type: "button", className: "slx-link", onClick: onBackToSignIn, children: "Back to sign in" }) }))] }));
|
|
40
|
+
}
|
|
41
|
+
return (_jsxs("div", { className: `slx-card${error ? ' slx-card-error' : ''}`, children: [_jsx("div", { className: "slx-mark", children: _jsx(KeyholeMark, {}) }), _jsx("h1", { className: "slx-title", children: "Reset your password" }), _jsx("p", { className: "slx-subtitle", children: "Enter your email and we'll send you a reset link." }), error && (_jsx("p", { className: "slx-error-text", role: "alert", children: error })), _jsxs("form", { onSubmit: onSubmit, children: [_jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-forgot-email", children: "Email" }), _jsx("input", { id: "slx-forgot-email", className: "slx-input", type: "email", autoComplete: "email", placeholder: "you@example.com", value: email, onChange: (e) => setEmail(e.target.value), required: true })] }), _jsxs("button", { className: "slx-btn", type: "submit", disabled: busy, children: [busy && _jsx("span", { className: "slx-spinner", "aria-hidden": "true" }), busy ? 'Sending…' : 'Send reset link'] })] }), onBackToSignIn && (_jsx("p", { className: "slx-footer", children: _jsx("button", { type: "button", className: "slx-link", onClick: onBackToSignIn, children: "Back to sign in" }) }))] }));
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=ForgotPassword.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ForgotPassword.js","sourceRoot":"","sources":["../../../src/components/ForgotPassword/ForgotPassword.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YA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AS,EAAC,WAAW,aACxB,gBAAO,SAAS,EAAC,WAAW,EAAC,OAAO,EAAC,kBAAkB,sBAE/C,EACR,gBACE,EAAE,EAAC,kBAAkB,EACrB,SAAS,EAAC,WAAW,EACrB,IAAI,EAAC,OAAO,EACZ,YAAY,EAAC,OAAO,EACpB,WAAW,EAAC,iBAAiB,EAC7B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACzC,QAAQ,SACR,IACE,EACN,kBAAQ,SAAS,EAAC,SAAS,EAAC,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,IAAI,aACrD,IAAI,IAAI,eAAM,SAAS,EAAC,aAAa,iBAAa,MAAM,GAAG,EAC3D,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,IAC/B,IACJ,EAEN,cAAc,IAAI,CACjB,YAAG,SAAS,EAAC,YAAY,YACvB,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,UAAU,EAAC,OAAO,EAAE,cAAc,gCAEzD,GACP,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ResetPasswordProps {
|
|
2
|
+
/** Reset token (from email link ?token=...) */
|
|
3
|
+
token: string;
|
|
4
|
+
apiUrl?: string;
|
|
5
|
+
onSuccess?: () => void;
|
|
6
|
+
}
|
|
7
|
+
/** Set a new password using the emailed reset token. */
|
|
8
|
+
export declare function ResetPassword({ token, apiUrl, onSuccess, }: ResetPasswordProps): import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=ResetPassword.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResetPassword.d.ts","sourceRoot":"","sources":["../../../src/components/ResetPassword/ResetPassword.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,MAAM,EACN,SAAS,GACV,EAAE,kBAAkB,+BAwGpB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { CheckIcon, KeyholeMark } from '../../icons';
|
|
4
|
+
/** Set a new password using the emailed reset token. */
|
|
5
|
+
export function ResetPassword({ token, apiUrl, onSuccess, }) {
|
|
6
|
+
const [password, setPassword] = useState('');
|
|
7
|
+
const [done, setDone] = useState(false);
|
|
8
|
+
const [busy, setBusy] = useState(false);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (error) {
|
|
12
|
+
const t = setTimeout(() => setError(null), 4000);
|
|
13
|
+
return () => clearTimeout(t);
|
|
14
|
+
}
|
|
15
|
+
}, [error]);
|
|
16
|
+
async function onSubmit(e) {
|
|
17
|
+
e.preventDefault();
|
|
18
|
+
setBusy(true);
|
|
19
|
+
setError(null);
|
|
20
|
+
try {
|
|
21
|
+
const base = (apiUrl ??
|
|
22
|
+
process.env.NEXT_PUBLIC_SLYXUP_API_URL ??
|
|
23
|
+
'https://auth.slyxup.online').replace(/\/$/, '');
|
|
24
|
+
const res = await fetch(`${base}/v1/verification/password/reset`, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: { 'Content-Type': 'application/json' },
|
|
27
|
+
body: JSON.stringify({ token, password }),
|
|
28
|
+
});
|
|
29
|
+
if (!res.ok) {
|
|
30
|
+
const data = await res
|
|
31
|
+
.json()
|
|
32
|
+
.catch(() => ({ error: 'Invalid or expired link' }));
|
|
33
|
+
throw new Error(data.error ?? 'Invalid or expired link');
|
|
34
|
+
}
|
|
35
|
+
setDone(true);
|
|
36
|
+
onSuccess?.();
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
setError(err instanceof Error ? err.message : 'Something went wrong.');
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
setBusy(false);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (done) {
|
|
46
|
+
return (_jsxs("div", { className: "slx-card", children: [_jsx("div", { className: "slx-success-icon", children: _jsx(CheckIcon, {}) }), _jsx("h1", { className: "slx-title", style: { textAlign: 'center' }, children: "Password updated" }), _jsx("p", { className: "slx-subtitle", style: { textAlign: 'center' }, children: "Your password has been changed. Use it to sign in." }), onSuccess && (_jsx("button", { type: "button", className: "slx-btn", onClick: onSuccess, children: "Continue to sign in" }))] }));
|
|
47
|
+
}
|
|
48
|
+
return (_jsxs("div", { className: `slx-card${error ? ' slx-card-error' : ''}`, children: [_jsx("div", { className: "slx-mark", children: _jsx(KeyholeMark, {}) }), _jsx("h1", { className: "slx-title", children: "Choose a new password" }), _jsx("p", { className: "slx-subtitle", children: "Pick something strong you haven't used before." }), error && (_jsx("p", { className: "slx-error-text", role: "alert", children: error })), _jsxs("form", { onSubmit: onSubmit, children: [_jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-reset-password", children: "New password" }), _jsx("input", { id: "slx-reset-password", className: "slx-input", type: "password", autoComplete: "new-password", placeholder: "At least 8 characters", value: password, onChange: (e) => setPassword(e.target.value), required: true, minLength: 8 })] }), _jsxs("button", { className: "slx-btn", type: "submit", disabled: busy, children: [busy && _jsx("span", { className: "slx-spinner", "aria-hidden": "true" }), busy ? 'Updating…' : 'Update password'] })] })] }));
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=ResetPassword.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResetPassword.js","sourceRoot":"","sources":["../../../src/components/ResetPassword/ResetPassword.ts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AC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,aACzD,cAAK,SAAS,EAAC,UAAU,YACvB,KAAC,WAAW,KAAG,GACX,EACN,aAAI,SAAS,EAAC,WAAW,sCAA2B,EACpD,YAAG,SAAS,EAAC,cAAc,+DAEvB,EAEH,KAAK,IAAI,CACR,YAAG,SAAS,EAAC,gBAAgB,EAAC,IAAI,EAAC,OAAO,YACvC,KAAK,GACJ,CACL,EAED,gBAAM,QAAQ,EAAE,QAAQ,aACtB,eAAK,SAAS,EAAC,WAAW,aACxB,gBAAO,SAAS,EAAC,WAAW,EAAC,OAAO,EAAC,oBAAoB,6BAEjD,EACR,gBACE,EAAE,EAAC,oBAAoB,EACvB,SAAS,EAAC,WAAW,EACrB,IAAI,EAAC,UAAU,EACf,YAAY,EAAC,cAAc,EAC3B,WAAW,EAAC,uBAAuB,EACnC,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,QAAQ,QACR,SAAS,EAAE,CAAC,GACZ,IACE,EACN,kBAAQ,SAAS,EAAC,SAAS,EAAC,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,IAAI,aACrD,IAAI,IAAI,eAAM,SAAS,EAAC,aAAa,iBAAa,MAAM,GAAG,EAC3D,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,iBAAiB,IAChC,IACJ,IACH,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface SignInProps {
|
|
2
|
+
/** Show social buttons (default true) */
|
|
3
|
+
social?: boolean;
|
|
4
|
+
/** Called after successful sign in */
|
|
5
|
+
onSuccess?: () => void;
|
|
6
|
+
/** Switch to sign up */
|
|
7
|
+
onSignUpClick?: () => void;
|
|
8
|
+
}
|
|
9
|
+
/** Email/password + OAuth sign-in card. */
|
|
10
|
+
export declare function SignIn({ social, onSuccess, onSignUpClick, }: SignInProps): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=SignIn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignIn.d.ts","sourceRoot":"","sources":["../../../src/components/SignIn/SignIn.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,wBAAwB;IACxB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,2CAA2C;AAC3C,wBAAgB,MAAM,CAAC,EACrB,MAAa,EACb,SAAS,EACT,aAAa,GACd,EAAE,WAAW,+BA2Hb"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { SlyxupError } from '@slyxup/core';
|
|
3
|
+
import { useAuth } from '@slyxup/react';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { GitHubIcon, GoogleIcon, KeyholeMark } from '../../icons';
|
|
6
|
+
/** Email/password + OAuth sign-in card. */
|
|
7
|
+
export function SignIn({ social = true, onSuccess, onSignUpClick, }) {
|
|
8
|
+
const { signIn } = useAuth();
|
|
9
|
+
const [email, setEmail] = useState('');
|
|
10
|
+
const [password, setPassword] = useState('');
|
|
11
|
+
const [busy, setBusy] = useState(false);
|
|
12
|
+
const [error, setError] = useState(null);
|
|
13
|
+
const cardRef = useRef(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (error) {
|
|
16
|
+
const t = setTimeout(() => setError(null), 4000);
|
|
17
|
+
return () => clearTimeout(t);
|
|
18
|
+
}
|
|
19
|
+
}, [error]);
|
|
20
|
+
async function onSubmit(e) {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
setBusy(true);
|
|
23
|
+
setError(null);
|
|
24
|
+
try {
|
|
25
|
+
await signIn({ email, password });
|
|
26
|
+
onSuccess?.();
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
setError(err instanceof SlyxupError
|
|
30
|
+
? err.message
|
|
31
|
+
: 'Something went wrong. Try again.');
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
setBusy(false);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function oauth(provider) {
|
|
38
|
+
window.location.href = `/v1/oauth/${provider}`;
|
|
39
|
+
}
|
|
40
|
+
return (_jsxs("div", { ref: cardRef, className: `slx-card${error ? ' slx-card-error' : ''}`, children: [_jsx("div", { className: "slx-mark", children: _jsx(KeyholeMark, {}) }), _jsx("h1", { className: "slx-title", children: "Sign in" }), _jsx("p", { className: "slx-subtitle", children: "Welcome back. Enter your details to continue." }), social && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "slx-social", children: [_jsxs("button", { type: "button", className: "slx-social-btn", onClick: () => oauth('google'), children: [_jsx(GoogleIcon, {}), " Continue with Google"] }), _jsxs("button", { type: "button", className: "slx-social-btn", onClick: () => oauth('github'), children: [_jsx(GitHubIcon, {}), " Continue with GitHub"] })] }), _jsx("div", { className: "slx-divider", children: "or" })] })), error && (_jsx("p", { className: "slx-error-text", role: "alert", children: error })), _jsxs("form", { onSubmit: onSubmit, noValidate: false, children: [_jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-signin-email", children: "Email" }), _jsx("input", { id: "slx-signin-email", className: "slx-input", type: "email", autoComplete: "email", placeholder: "you@example.com", value: email, onChange: (e) => setEmail(e.target.value), required: true })] }), _jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-signin-password", children: "Password" }), _jsx("input", { id: "slx-signin-password", className: "slx-input", type: "password", autoComplete: "current-password", placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022", value: password, onChange: (e) => setPassword(e.target.value), required: true, minLength: 8 })] }), _jsxs("button", { className: "slx-btn", type: "submit", disabled: busy, children: [busy && _jsx("span", { className: "slx-spinner", "aria-hidden": "true" }), busy ? 'Signing in…' : 'Sign in'] })] }), onSignUpClick && (_jsxs("p", { className: "slx-footer", children: ["Don't have an account?", ' ', _jsx("button", { type: "button", className: "slx-link", onClick: onSignUpClick, children: "Sign up" })] }))] }));
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=SignIn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignIn.js","sourceRoot":"","sources":["../../../src/components/SignIn/SignIn.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAkB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAWlE,2CAA2C;AAC3C,MAAM,UAAU,MAAM,CAAC,EACrB,MAAM,GAAG,IAAI,EACb,SAAS,EACT,aAAa,GACD;IACZ,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;IAC7B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC7C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAE7C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,KAAK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C,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,IAAI,aACrD,IAAI,IAAI,eAAM,SAAS,EAAC,aAAa,iBAAa,MAAM,GAAG,EAC3D,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,IAC1B,IACJ,EAEN,aAAa,IAAI,CAChB,aAAG,SAAS,EAAC,YAAY,uCACK,GAAG,EAC/B,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,UAAU,EAAC,OAAO,EAAE,aAAa,wBAExD,IACP,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface SignUpProps {
|
|
2
|
+
social?: boolean;
|
|
3
|
+
onSuccess?: () => void;
|
|
4
|
+
onSignInClick?: () => void;
|
|
5
|
+
}
|
|
6
|
+
/** Email/password + OAuth sign-up card. */
|
|
7
|
+
export declare function SignUp({ social, onSuccess, onSignInClick, }: SignUpProps): import("react").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=SignUp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignUp.d.ts","sourceRoot":"","sources":["../../../src/components/SignUp/SignUp.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,2CAA2C;AAC3C,wBAAgB,MAAM,CAAC,EACrB,MAAa,EACb,SAAS,EACT,aAAa,GACd,EAAE,WAAW,+BA2Ib"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { SlyxupError } from '@slyxup/core';
|
|
3
|
+
import { useAuth } from '@slyxup/react';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { GitHubIcon, GoogleIcon, KeyholeMark } from '../../icons';
|
|
6
|
+
/** Email/password + OAuth sign-up card. */
|
|
7
|
+
export function SignUp({ social = true, onSuccess, onSignInClick, }) {
|
|
8
|
+
const { signUp } = useAuth();
|
|
9
|
+
const [firstName, setFirstName] = useState('');
|
|
10
|
+
const [email, setEmail] = useState('');
|
|
11
|
+
const [password, setPassword] = useState('');
|
|
12
|
+
const [busy, setBusy] = useState(false);
|
|
13
|
+
const [error, setError] = useState(null);
|
|
14
|
+
const cardRef = useRef(null);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (error) {
|
|
17
|
+
const t = setTimeout(() => setError(null), 4000);
|
|
18
|
+
return () => clearTimeout(t);
|
|
19
|
+
}
|
|
20
|
+
}, [error]);
|
|
21
|
+
async function onSubmit(e) {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
setBusy(true);
|
|
24
|
+
setError(null);
|
|
25
|
+
try {
|
|
26
|
+
await signUp({ email, password, firstName: firstName || undefined });
|
|
27
|
+
onSuccess?.();
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
setError(err instanceof SlyxupError
|
|
31
|
+
? err.message
|
|
32
|
+
: 'Something went wrong. Try again.');
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
setBusy(false);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function oauth(provider) {
|
|
39
|
+
window.location.href = `/v1/oauth/${provider}`;
|
|
40
|
+
}
|
|
41
|
+
return (_jsxs("div", { ref: cardRef, className: `slx-card${error ? ' slx-card-error' : ''}`, children: [_jsx("div", { className: "slx-mark", children: _jsx(KeyholeMark, {}) }), _jsx("h1", { className: "slx-title", children: "Create your account" }), _jsx("p", { className: "slx-subtitle", children: "A minute to set up. Sign in forever after." }), social && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "slx-social", children: [_jsxs("button", { type: "button", className: "slx-social-btn", onClick: () => oauth('google'), children: [_jsx(GoogleIcon, {}), " Continue with Google"] }), _jsxs("button", { type: "button", className: "slx-social-btn", onClick: () => oauth('github'), children: [_jsx(GitHubIcon, {}), " Continue with GitHub"] })] }), _jsx("div", { className: "slx-divider", children: "or" })] })), error && (_jsx("p", { className: "slx-error-text", role: "alert", children: error })), _jsxs("form", { onSubmit: onSubmit, children: [_jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-signup-name", children: "First name" }), _jsx("input", { id: "slx-signup-name", className: "slx-input", type: "text", autoComplete: "given-name", placeholder: "Ada", value: firstName, onChange: (e) => setFirstName(e.target.value) })] }), _jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-signup-email", children: "Email" }), _jsx("input", { id: "slx-signup-email", className: "slx-input", type: "email", autoComplete: "email", placeholder: "you@example.com", value: email, onChange: (e) => setEmail(e.target.value), required: true })] }), _jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-signup-password", children: "Password" }), _jsx("input", { id: "slx-signup-password", className: "slx-input", type: "password", autoComplete: "new-password", placeholder: "At least 8 characters", value: password, onChange: (e) => setPassword(e.target.value), required: true, minLength: 8 }), _jsx("p", { className: "slx-hint", children: "Use 8+ characters with a mix of letters and numbers." })] }), _jsxs("button", { className: "slx-btn", type: "submit", disabled: busy, children: [busy && _jsx("span", { className: "slx-spinner", "aria-hidden": "true" }), busy ? 'Creating account…' : 'Create account'] })] }), onSignInClick && (_jsxs("p", { className: "slx-footer", children: ["Already have an account?", ' ', _jsx("button", { type: "button", className: "slx-link", onClick: onSignInClick, children: "Sign in" })] }))] }));
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=SignUp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignUp.js","sourceRoot":"","sources":["../../../src/components/SignUp/SignUp.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,OAAO,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EAAC,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,IAAI,aACrD,IAAI,IAAI,eAAM,SAAS,EAAC,aAAa,iBAAa,MAAM,GAAG,EAC3D,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,gBAAgB,IACvC,IACJ,EAEN,aAAa,IAAI,CAChB,aAAG,SAAS,EAAC,YAAY,yCACE,GAAG,EAC5B,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,UAAU,EAAC,OAAO,EAAE,aAAa,wBAExD,IACP,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface SocialButtonsProps {
|
|
2
|
+
/** Show only these providers. Default: both */
|
|
3
|
+
providers?: Array<'google' | 'github'>;
|
|
4
|
+
/** OAuth start path base (default /v1/oauth) */
|
|
5
|
+
basePath?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Provider buttons that redirect to hosted OAuth start. */
|
|
8
|
+
export declare function SocialButtons({ providers, basePath, }: SocialButtonsProps): import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=SocialButtons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialButtons.d.ts","sourceRoot":"","sources":["../../../src/components/SocialButtons/SocialButtons.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;IACvC,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAOD,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,EAC5B,SAAgC,EAChC,QAAsB,GACvB,EAAE,kBAAkB,+BAoBpB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { GitHubIcon, GoogleIcon } from '../../icons';
|
|
3
|
+
const META = {
|
|
4
|
+
google: { label: 'Continue with Google', Icon: GoogleIcon },
|
|
5
|
+
github: { label: 'Continue with GitHub', Icon: GitHubIcon },
|
|
6
|
+
};
|
|
7
|
+
/** Provider buttons that redirect to hosted OAuth start. */
|
|
8
|
+
export function SocialButtons({ providers = ['google', 'github'], basePath = '/v1/oauth', }) {
|
|
9
|
+
return (_jsx("div", { className: "slx-social", children: providers.map((p) => {
|
|
10
|
+
const { label, Icon } = META[p];
|
|
11
|
+
return (_jsxs("button", { type: "button", className: "slx-social-btn", onClick: () => {
|
|
12
|
+
window.location.href = `${basePath}/${p}`;
|
|
13
|
+
}, children: [_jsx(Icon, {}), " ", label] }, p));
|
|
14
|
+
}) }));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=SocialButtons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialButtons.js","sourceRoot":"","sources":["../../../src/components/SocialButtons/SocialButtons.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AASrD,MAAM,IAAI,GAAG;IACX,MAAM,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE,IAAI,EAAE,UAAU,EAAE;IAC3D,MAAM,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE,IAAI,EAAE,UAAU,EAAE;CACnD,CAAC;AAEX,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,EAC5B,SAAS,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAChC,QAAQ,GAAG,WAAW,GACH;IACnB,OAAO,CACL,cAAK,SAAS,EAAC,YAAY,YACxB,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACnB,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAChC,OAAO,CACL,kBAEE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,gBAAgB,EAC1B,OAAO,EAAE,GAAG,EAAE;oBACZ,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,QAAQ,IAAI,CAAC,EAAE,CAAC;gBAC5C,CAAC,aAED,KAAC,IAAI,KAAG,OAAE,KAAK,KAPV,CAAC,CAQC,CACV,CAAC;QACJ,CAAC,CAAC,GACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserButton.d.ts","sourceRoot":"","sources":["../../../src/components/UserButton/UserButton.tsx"],"names":[],"mappings":"AAQA,2DAA2D;AAC3D,wBAAgB,UAAU,gCA+EzB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth, useUser } from '@slyxup/react';
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
function initials(name, email) {
|
|
5
|
+
if (name?.trim())
|
|
6
|
+
return name.trim().slice(0, 1).toUpperCase();
|
|
7
|
+
return email.slice(0, 1).toUpperCase();
|
|
8
|
+
}
|
|
9
|
+
/** Avatar + dropdown with profile actions and sign out. */
|
|
10
|
+
export function UserButton() {
|
|
11
|
+
const { isLoaded, user } = useUser();
|
|
12
|
+
const { signOut } = useAuth();
|
|
13
|
+
const [open, setOpen] = useState(false);
|
|
14
|
+
const wrapRef = useRef(null);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
function onDocClick(e) {
|
|
17
|
+
if (wrapRef.current && !wrapRef.current.contains(e.target))
|
|
18
|
+
setOpen(false);
|
|
19
|
+
}
|
|
20
|
+
function onKey(e) {
|
|
21
|
+
if (e.key === 'Escape')
|
|
22
|
+
setOpen(false);
|
|
23
|
+
}
|
|
24
|
+
document.addEventListener('mousedown', onDocClick);
|
|
25
|
+
document.addEventListener('keydown', onKey);
|
|
26
|
+
return () => {
|
|
27
|
+
document.removeEventListener('mousedown', onDocClick);
|
|
28
|
+
document.removeEventListener('keydown', onKey);
|
|
29
|
+
};
|
|
30
|
+
}, []);
|
|
31
|
+
if (!isLoaded)
|
|
32
|
+
return _jsx("div", { className: "slx-userbtn-avatar", "aria-hidden": "true" });
|
|
33
|
+
const email = user?.email ?? '';
|
|
34
|
+
const name = user?.firstName;
|
|
35
|
+
async function onSignOut() {
|
|
36
|
+
await signOut();
|
|
37
|
+
setOpen(false);
|
|
38
|
+
}
|
|
39
|
+
return (_jsxs("div", { className: "slx-userbtn-wrap", ref: wrapRef, children: [_jsx("button", { type: "button", className: "slx-userbtn-avatar", onClick: () => setOpen((o) => !o), "aria-haspopup": "menu", "aria-expanded": open, "aria-label": "Account menu", children: user?.avatarUrl ? (_jsx("img", { src: user.avatarUrl, alt: "" })) : (initials(name, email || '?')) }), open && (_jsxs("div", { className: "slx-menu", role: "menu", children: [_jsxs("div", { className: "slx-menu-header", children: [_jsx("p", { className: "slx-menu-name", children: name
|
|
40
|
+
? `${name}${user?.lastName ? ` ${user.lastName}` : ''}`
|
|
41
|
+
: email.split('@')[0] }), _jsx("p", { className: "slx-menu-email", children: email })] }), _jsx("button", { type: "button", className: "slx-menu-item", role: "menuitem", onClick: () => setOpen(false), children: "Profile settings" }), _jsx("button", { type: "button", className: "slx-menu-item slx-menu-item-danger", role: "menuitem", onClick: onSignOut, children: "Sign out" })] }))] }));
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=UserButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserButton.js","sourceRoot":"","sources":["../../../src/components/UserButton/UserButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,SAAS,QAAQ,CAAC,IAA+B,EAAE,KAAa;IAC9D,IAAI,IAAI,EAAE,IAAI,EAAE;QAAE,OAAO,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