@llmnative/react 2.1.0 → 2.2.1
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.css +1 -1
- package/dist/index.js +21 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10322 -8474
- package/dist/index.mjs.map +1 -1
- package/dist/types/src/App.d.ts +10 -1
- package/dist/types/src/I18n.d.ts +93 -0
- package/dist/types/src/components/auth/AuthGate.d.ts +26 -0
- package/dist/types/src/components/auth/AuthLayout.d.ts +38 -0
- package/dist/types/src/components/auth/ForgotPassword.d.ts +19 -0
- package/dist/types/src/components/auth/OneTimeCodeInput.d.ts +27 -0
- package/dist/types/src/components/auth/ResetPassword.d.ts +31 -0
- package/dist/types/src/components/auth/SignIn.d.ts +42 -0
- package/dist/types/src/components/auth/SignUp.d.ts +43 -0
- package/dist/types/src/components/auth/VerifyCode.d.ts +32 -0
- package/dist/types/src/components/auth/VerifyEmail.d.ts +31 -0
- package/dist/types/src/components/auth/index.d.ts +12 -0
- package/dist/types/src/components/auth/providers.d.ts +22 -0
- package/dist/types/src/components/auth/shared.d.ts +124 -0
- package/dist/types/src/components/auth/useAuthFlows.d.ts +46 -0
- package/dist/types/src/index.d.ts +5 -1
- package/dist/types/src/providers/auth/AuthProvider.d.ts +51 -0
- package/dist/types/src/providers/auth/firebase/FirebaseAuthProvider.d.ts +8 -1
- package/dist/types/src/providers/auth/github/GitHubAuthProvider.d.ts +2 -0
- package/dist/types/src/providers/auth/mock/MockAuthProvider.d.ts +55 -0
- package/dist/types/src/providers/auth/supabase/SupabaseAuthProvider.d.ts +16 -1
- package/dist/types/src/providers/manifest.d.ts +4 -1
- package/llms-full.txt +66 -2
- package/package.json +1 -1
- package/scripts/cli/setup-project.js +678 -667
- package/templates/_shared/conf/access.tsx +23 -0
- package/templates/_shared/pages/access/ForgotPasswordPage.tsx +13 -0
- package/templates/_shared/pages/access/ResetPasswordPage.tsx +19 -0
- package/templates/_shared/pages/access/SignInPage.tsx +21 -0
- package/templates/_shared/pages/access/SignUpPage.tsx +23 -0
- package/templates/_shared/pages/access/VerifyEmailPage.tsx +20 -0
- package/templates/_shared/pages/access/paths.ts +12 -0
- package/templates/_shared/sections/Footer.tsx +9 -9
- package/templates/_shared/sections/Header.tsx +26 -24
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MenuConfig } from '@llmnative/react';
|
|
3
|
+
import SignUpPage from '../pages/access/SignUpPage';
|
|
4
|
+
import ForgotPasswordPage from '../pages/access/ForgotPasswordPage';
|
|
5
|
+
import ResetPasswordPage from '../pages/access/ResetPasswordPage';
|
|
6
|
+
import VerifyEmailPage from '../pages/access/VerifyEmailPage';
|
|
7
|
+
import { ACCESS_PATHS } from '../pages/access/paths';
|
|
8
|
+
|
|
9
|
+
/** The pages of access take the whole screen: no header, no menu. */
|
|
10
|
+
const Bare = ({ children }: { children?: React.ReactNode }) => <>{children}</>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The pages open without a session (`public`): the sign-in itself has no page, the gate of
|
|
14
|
+
* `index.tsx` shows it in place of any other page. No title: they are never entries of a menu.
|
|
15
|
+
*/
|
|
16
|
+
export const accessMenu: MenuConfig = {
|
|
17
|
+
access: [
|
|
18
|
+
{ path: ACCESS_PATHS.signUp, page: SignUpPage, layout: Bare, public: true },
|
|
19
|
+
{ path: ACCESS_PATHS.forgotPassword, page: ForgotPasswordPage, layout: Bare, public: true },
|
|
20
|
+
{ path: ACCESS_PATHS.resetPassword, page: ResetPasswordPage, layout: Bare, public: true },
|
|
21
|
+
{ path: ACCESS_PATHS.verifyEmail, page: VerifyEmailPage, layout: Bare, public: true },
|
|
22
|
+
],
|
|
23
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Navigate } from 'react-router-dom';
|
|
3
|
+
import { Brand, ForgotPassword, useAuthFlows } from '@llmnative/react';
|
|
4
|
+
import { ACCESS_FLOWS } from './paths';
|
|
5
|
+
|
|
6
|
+
/** Sends the link to choose a new password; the link opens `/reset-password`. */
|
|
7
|
+
export default function ForgotPasswordPage() {
|
|
8
|
+
const flows = useAuthFlows(undefined, ACCESS_FLOWS);
|
|
9
|
+
|
|
10
|
+
if (!flows.forgotPassword) return <Navigate to="/" replace />;
|
|
11
|
+
|
|
12
|
+
return <ForgotPassword {...flows.forgotPassword} brand={<Brand label="[projectname]" />} signInLink="/" />;
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
import { Brand, ResetPassword, linkCode, useAuthFlows } from '@llmnative/react';
|
|
4
|
+
import { ACCESS_FLOWS, ACCESS_PATHS } from './paths';
|
|
5
|
+
|
|
6
|
+
/** Opened by the link of the email: the code of the link sets the new password. */
|
|
7
|
+
export default function ResetPasswordPage() {
|
|
8
|
+
const flows = useAuthFlows(undefined, ACCESS_FLOWS);
|
|
9
|
+
const code = linkCode(useLocation().search);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<ResetPassword
|
|
13
|
+
{...flows.resetPassword(code)}
|
|
14
|
+
brand={<Brand label="[projectname]" />}
|
|
15
|
+
signInLink="/"
|
|
16
|
+
requestNewLink={ACCESS_PATHS.forgotPassword}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Brand, SignIn, useAuthFlows } from '@llmnative/react';
|
|
3
|
+
import { ACCESS_FLOWS, ACCESS_PATHS } from './paths';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The sign-in, shown by the gate of `index.tsx` in place of any page opened without a session:
|
|
7
|
+
* the address does not change, and once signed in the page appears.
|
|
8
|
+
*/
|
|
9
|
+
export default function SignInPage() {
|
|
10
|
+
const flows = useAuthFlows(undefined, ACCESS_FLOWS);
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<SignIn
|
|
14
|
+
{...flows.signIn}
|
|
15
|
+
appName="[projectname]"
|
|
16
|
+
brand={<Brand label="[projectname]" />}
|
|
17
|
+
signUpLink={flows.signUp ? ACCESS_PATHS.signUp : undefined}
|
|
18
|
+
forgotPasswordLink={flows.forgotPassword ? ACCESS_PATHS.forgotPassword : undefined}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Navigate, useNavigate } from 'react-router-dom';
|
|
3
|
+
import { Brand, SignUp, useAuthFlows } from '@llmnative/react';
|
|
4
|
+
import { ACCESS_FLOWS } from './paths';
|
|
5
|
+
|
|
6
|
+
/** Creates an account; the confirmation link of the email opens `/verify-email`. */
|
|
7
|
+
export default function SignUpPage() {
|
|
8
|
+
const flows = useAuthFlows(undefined, ACCESS_FLOWS);
|
|
9
|
+
const navigate = useNavigate();
|
|
10
|
+
|
|
11
|
+
// A provider without accounts of its own (Google, GitHub): its sign-in creates them.
|
|
12
|
+
if (!flows.signUp) return <Navigate to="/" replace />;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<SignUp
|
|
16
|
+
{...flows.signUp}
|
|
17
|
+
terms
|
|
18
|
+
brand={<Brand label="[projectname]" />}
|
|
19
|
+
signInLink="/"
|
|
20
|
+
onSignedUp={() => navigate('/')}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
import { Brand, VerifyEmail, linkCode, useAuthFlows } from '@llmnative/react';
|
|
4
|
+
import { ACCESS_FLOWS } from './paths';
|
|
5
|
+
|
|
6
|
+
/** Opened by the confirmation link of a new account: it activates the account at once. */
|
|
7
|
+
export default function VerifyEmailPage() {
|
|
8
|
+
const flows = useAuthFlows(undefined, ACCESS_FLOWS);
|
|
9
|
+
const code = linkCode(useLocation().search);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<VerifyEmail
|
|
13
|
+
{...flows.verifyEmail}
|
|
14
|
+
code={code}
|
|
15
|
+
brand={<Brand label="[projectname]" />}
|
|
16
|
+
continueLink="/"
|
|
17
|
+
signInLink="/"
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// The pages the links of the access emails open: the provider puts them in the emails it sends.
|
|
2
|
+
export const ACCESS_PATHS = {
|
|
3
|
+
signUp: '/sign-up',
|
|
4
|
+
forgotPassword: '/forgot-password',
|
|
5
|
+
resetPassword: '/reset-password',
|
|
6
|
+
verifyEmail: '/verify-email',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const ACCESS_FLOWS = {
|
|
10
|
+
verifyEmailPath: ACCESS_PATHS.verifyEmail,
|
|
11
|
+
resetPasswordPath: ACCESS_PATHS.resetPassword,
|
|
12
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
export default function Footer() {
|
|
4
|
-
return (
|
|
5
|
-
<footer className="shrink-0 border-t border-footer-border bg-footer px-4 py-1.5 text-end text-xs text-footer-foreground">
|
|
6
|
-
|
|
7
|
-
</footer>
|
|
8
|
-
);
|
|
9
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export default function Footer() {
|
|
4
|
+
return (
|
|
5
|
+
<footer className="shrink-0 border-t border-footer-border bg-footer px-4 py-1.5 text-end text-xs text-footer-foreground">
|
|
6
|
+
© {new Date().getFullYear()} [projectname]
|
|
7
|
+
</footer>
|
|
8
|
+
);
|
|
9
|
+
}
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ActionButton, AuthButton, Brand } from '@llmnative/react';
|
|
3
|
-
|
|
4
|
-
type HeaderProps = {
|
|
5
|
-
onMenuToggle: () => void;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export default function Header({ onMenuToggle }: HeaderProps) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ActionButton, AuthButton, Brand, useI18n } from '@llmnative/react';
|
|
3
|
+
|
|
4
|
+
type HeaderProps = {
|
|
5
|
+
onMenuToggle: () => void;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default function Header({ onMenuToggle }: HeaderProps) {
|
|
9
|
+
const common = useI18n('common');
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<header className="flex h-14 shrink-0 items-center gap-3 border-b border-header-border bg-header px-4 text-header-foreground">
|
|
13
|
+
<ActionButton
|
|
14
|
+
icon="menu"
|
|
15
|
+
ariaLabel={common.openNavigation}
|
|
16
|
+
variant="link"
|
|
17
|
+
wrapperClassName="lg:hidden"
|
|
18
|
+
onClick={onMenuToggle}
|
|
19
|
+
/>
|
|
20
|
+
<Brand url="/" label="[projectname]" />
|
|
21
|
+
<div className="ms-auto">
|
|
22
|
+
<AuthButton aspect="avatar" />
|
|
23
|
+
</div>
|
|
24
|
+
</header>
|
|
25
|
+
);
|
|
26
|
+
}
|