@object-ui/auth 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -147,7 +147,7 @@ import { AuthProvider, PreviewBanner } from '@object-ui/auth';
147
147
  function App() {
148
148
  return (
149
149
  <AuthProvider
150
- authUrl="/api/auth"
150
+ authUrl="/api/v1/auth"
151
151
  previewMode={{
152
152
  simulatedRole: 'admin',
153
153
  simulatedUserName: 'Demo Admin',
@@ -31,20 +31,20 @@ export interface AuthProviderProps extends AuthProviderConfig {
31
31
  *
32
32
  * @example
33
33
  * ```tsx
34
- * <AuthProvider authUrl="/api/auth">
34
+ * <AuthProvider authUrl="/api/v1/auth">
35
35
  * <App />
36
36
  * </AuthProvider>
37
37
  * ```
38
38
  *
39
39
  * @example With disabled auth (development mode)
40
40
  * ```tsx
41
- * <AuthProvider authUrl="/api/auth" enabled={false}>
41
+ * <AuthProvider authUrl="/api/v1/auth" enabled={false}>
42
42
  * <App />
43
43
  * </AuthProvider>
44
44
  * ```
45
45
  * @example With preview mode (marketplace demo)
46
46
  * ```tsx
47
- * <AuthProvider authUrl="/api/auth" previewMode={{ simulatedRole: 'admin', bannerMessage: 'Demo mode' }}>
47
+ * <AuthProvider authUrl="/api/v1/auth" previewMode={{ simulatedRole: 'admin', bannerMessage: 'Demo mode' }}>
48
48
  * <App />
49
49
  * </AuthProvider>
50
50
  * ```
@@ -17,20 +17,20 @@ import { createAuthClient } from './createAuthClient';
17
17
  *
18
18
  * @example
19
19
  * ```tsx
20
- * <AuthProvider authUrl="/api/auth">
20
+ * <AuthProvider authUrl="/api/v1/auth">
21
21
  * <App />
22
22
  * </AuthProvider>
23
23
  * ```
24
24
  *
25
25
  * @example With disabled auth (development mode)
26
26
  * ```tsx
27
- * <AuthProvider authUrl="/api/auth" enabled={false}>
27
+ * <AuthProvider authUrl="/api/v1/auth" enabled={false}>
28
28
  * <App />
29
29
  * </AuthProvider>
30
30
  * ```
31
31
  * @example With preview mode (marketplace demo)
32
32
  * ```tsx
33
- * <AuthProvider authUrl="/api/auth" previewMode={{ simulatedRole: 'admin', bannerMessage: 'Demo mode' }}>
33
+ * <AuthProvider authUrl="/api/v1/auth" previewMode={{ simulatedRole: 'admin', bannerMessage: 'Demo mode' }}>
34
34
  * <App />
35
35
  * </AuthProvider>
36
36
  * ```
@@ -5,6 +5,20 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import React from 'react';
9
+ import type { AuthLinkComponentProps } from './types';
10
+ /** Translatable labels for the ForgotPasswordForm */
11
+ export interface ForgotPasswordFormLabels {
12
+ emailLabel?: string;
13
+ emailPlaceholder?: string;
14
+ submitButton?: string;
15
+ submittingButton?: string;
16
+ successTitle?: string;
17
+ successDescription?: string;
18
+ backToSignInText?: string;
19
+ rememberPasswordText?: string;
20
+ signInText?: string;
21
+ }
8
22
  export interface ForgotPasswordFormProps {
9
23
  /** Callback on successful submission */
10
24
  onSuccess?: () => void;
@@ -16,6 +30,10 @@ export interface ForgotPasswordFormProps {
16
30
  title?: string;
17
31
  /** Custom description */
18
32
  description?: string;
33
+ /** Custom link component for SPA navigation (e.g. React Router's Link) */
34
+ linkComponent?: React.ComponentType<AuthLinkComponentProps>;
35
+ /** Override default labels for i18n */
36
+ labels?: ForgotPasswordFormLabels;
19
37
  }
20
38
  /**
21
39
  * Forgot password form component.
@@ -29,5 +47,5 @@ export interface ForgotPasswordFormProps {
29
47
  * />
30
48
  * ```
31
49
  */
32
- export declare function ForgotPasswordForm({ onSuccess, onError, loginUrl, title, description, }: ForgotPasswordFormProps): import("react/jsx-runtime").JSX.Element;
50
+ export declare function ForgotPasswordForm({ onSuccess, onError, loginUrl, title, description, linkComponent: LinkComp, labels, }: ForgotPasswordFormProps): import("react/jsx-runtime").JSX.Element;
33
51
  //# sourceMappingURL=ForgotPasswordForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ForgotPasswordForm.d.ts","sourceRoot":"","sources":["../src/ForgotPasswordForm.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,WAAW,uBAAuB;IACtC,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,wBAAwB;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,EACT,OAAO,EACP,QAAmB,EACnB,KAA6B,EAC7B,WAA0F,GAC3F,EAAE,uBAAuB,2CA4FzB"}
1
+ {"version":3,"file":"ForgotPasswordForm.d.ts","sourceRoot":"","sources":["../src/ForgotPasswordForm.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,qDAAqD;AACrD,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,uBAAuB;IACtC,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,wBAAwB;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,sBAAsB,CAAC,CAAC;IAC5D,uCAAuC;IACvC,MAAM,CAAC,EAAE,wBAAwB,CAAC;CACnC;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,EACT,OAAO,EACP,QAAmB,EACnB,KAA6B,EAC7B,WAA0F,EAC1F,aAAa,EAAE,QAAsB,EACrC,MAAW,GACZ,EAAE,uBAAuB,2CAwGzB"}
@@ -8,6 +8,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
8
  */
9
9
  import { useState } from 'react';
10
10
  import { useAuth } from './useAuth';
11
+ const DefaultLink = ({ href, className, children }) => (_jsx("a", { href: href, className: className, children: children }));
11
12
  /**
12
13
  * Forgot password form component.
13
14
  * Sends a password reset email to the user.
@@ -20,11 +21,22 @@ import { useAuth } from './useAuth';
20
21
  * />
21
22
  * ```
22
23
  */
23
- export function ForgotPasswordForm({ onSuccess, onError, loginUrl = '/login', title = 'Reset your password', description = 'Enter your email address and we\'ll send you a link to reset your password', }) {
24
+ export function ForgotPasswordForm({ onSuccess, onError, loginUrl = '/login', title = 'Reset your password', description = 'Enter your email address and we\'ll send you a link to reset your password', linkComponent: LinkComp = DefaultLink, labels = {}, }) {
24
25
  const { forgotPassword, isLoading } = useAuth();
25
26
  const [email, setEmail] = useState('');
26
27
  const [error, setError] = useState(null);
27
28
  const [submitted, setSubmitted] = useState(false);
29
+ const l = {
30
+ emailLabel: labels.emailLabel ?? 'Email',
31
+ emailPlaceholder: labels.emailPlaceholder ?? 'name@example.com',
32
+ submitButton: labels.submitButton ?? 'Send Reset Link',
33
+ submittingButton: labels.submittingButton ?? 'Sending...',
34
+ successTitle: labels.successTitle ?? 'Check your email',
35
+ successDescription: labels.successDescription ?? "We've sent a password reset link to {{email}}. Please check your inbox.",
36
+ backToSignInText: labels.backToSignInText ?? 'Back to sign in',
37
+ rememberPasswordText: labels.rememberPasswordText ?? 'Remember your password?',
38
+ signInText: labels.signInText ?? 'Sign in',
39
+ };
28
40
  const handleSubmit = async (e) => {
29
41
  e.preventDefault();
30
42
  setError(null);
@@ -40,7 +52,10 @@ export function ForgotPasswordForm({ onSuccess, onError, loginUrl = '/login', ti
40
52
  }
41
53
  };
42
54
  if (submitted) {
43
- return (_jsxs("div", { className: "mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]", children: [_jsxs("div", { className: "flex flex-col space-y-2 text-center", children: [_jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: "Check your email" }), _jsxs("p", { className: "text-sm text-muted-foreground", children: ["We've sent a password reset link to ", _jsx("strong", { children: email }), ". Please check your inbox and follow the instructions."] })] }), loginUrl && (_jsx("p", { className: "px-8 text-center text-sm text-muted-foreground", children: _jsx("a", { href: loginUrl, className: "text-primary underline-offset-4 hover:underline", children: "Back to sign in" }) }))] }));
55
+ const successMsg = l.successDescription.includes('{{email}}')
56
+ ? l.successDescription.replace('{{email}}', email)
57
+ : `${l.successDescription} ${email}`;
58
+ return (_jsxs("div", { className: "mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[380px]", children: [_jsxs("div", { className: "flex flex-col space-y-2 text-center", children: [_jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: l.successTitle }), _jsx("p", { className: "text-sm text-muted-foreground", children: successMsg })] }), loginUrl && (_jsx("p", { className: "px-8 text-center text-sm text-muted-foreground", children: _jsx(LinkComp, { href: loginUrl, className: "text-primary underline-offset-4 hover:underline", children: l.backToSignInText }) }))] }));
44
59
  }
45
- return (_jsxs("div", { className: "mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]", children: [_jsxs("div", { className: "flex flex-col space-y-2 text-center", children: [_jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: title }), _jsx("p", { className: "text-sm text-muted-foreground", children: description })] }), _jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [error && (_jsx("div", { className: "rounded-md bg-destructive/15 p-3 text-sm text-destructive", role: "alert", children: error })), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "forgot-email", className: "text-sm font-medium leading-none", children: "Email" }), _jsx("input", { id: "forgot-email", type: "email", placeholder: "name@example.com", value: email, onChange: (e) => setEmail(e.target.value), required: true, autoComplete: "email", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsx("button", { type: "submit", disabled: isLoading, className: "inline-flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground ring-offset-background transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", children: isLoading ? 'Sending...' : 'Send Reset Link' })] }), loginUrl && (_jsxs("p", { className: "px-8 text-center text-sm text-muted-foreground", children: ["Remember your password?", ' ', _jsx("a", { href: loginUrl, className: "text-primary underline-offset-4 hover:underline", children: "Sign in" })] }))] }));
60
+ return (_jsxs("div", { className: "mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[380px]", children: [_jsxs("div", { className: "flex flex-col space-y-2 text-center", children: [_jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: title }), _jsx("p", { className: "text-sm text-muted-foreground", children: description })] }), _jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [error && (_jsx("div", { className: "rounded-md bg-destructive/15 p-3 text-sm text-destructive", role: "alert", children: error })), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "forgot-email", className: "text-sm font-medium leading-none", children: l.emailLabel }), _jsx("input", { id: "forgot-email", type: "email", placeholder: l.emailPlaceholder, value: email, onChange: (e) => setEmail(e.target.value), required: true, autoComplete: "email", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsx("button", { type: "submit", disabled: isLoading, className: "inline-flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground ring-offset-background transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", children: isLoading ? l.submittingButton : l.submitButton })] }), loginUrl && (_jsxs("p", { className: "px-8 text-center text-sm text-muted-foreground", children: [l.rememberPasswordText, ' ', _jsx(LinkComp, { href: loginUrl, className: "text-primary underline-offset-4 hover:underline", children: l.signInText })] }))] }));
46
61
  }
@@ -5,6 +5,20 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import React from 'react';
9
+ import type { AuthLinkComponentProps } from './types';
10
+ /** Translatable labels for the LoginForm */
11
+ export interface LoginFormLabels {
12
+ emailLabel?: string;
13
+ emailPlaceholder?: string;
14
+ passwordLabel?: string;
15
+ passwordPlaceholder?: string;
16
+ forgotPasswordText?: string;
17
+ submitButton?: string;
18
+ submittingButton?: string;
19
+ noAccountText?: string;
20
+ signUpText?: string;
21
+ }
8
22
  export interface LoginFormProps {
9
23
  /** Callback on successful login */
10
24
  onSuccess?: () => void;
@@ -18,6 +32,10 @@ export interface LoginFormProps {
18
32
  title?: string;
19
33
  /** Custom description */
20
34
  description?: string;
35
+ /** Custom link component for SPA navigation (e.g. React Router's Link) */
36
+ linkComponent?: React.ComponentType<AuthLinkComponentProps>;
37
+ /** Override default labels for i18n */
38
+ labels?: LoginFormLabels;
21
39
  }
22
40
  /**
23
41
  * Login form component with email/password authentication.
@@ -32,5 +50,5 @@ export interface LoginFormProps {
32
50
  * />
33
51
  * ```
34
52
  */
35
- export declare function LoginForm({ onSuccess, onError, registerUrl, forgotPasswordUrl, title, description, }: LoginFormProps): import("react/jsx-runtime").JSX.Element;
53
+ export declare function LoginForm({ onSuccess, onError, registerUrl, forgotPasswordUrl, title, description, linkComponent: LinkComp, labels, }: LoginFormProps): import("react/jsx-runtime").JSX.Element;
36
54
  //# sourceMappingURL=LoginForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoginForm.d.ts","sourceRoot":"","sources":["../src/LoginForm.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,EACxB,SAAS,EACT,OAAO,EACP,WAAyB,EACzB,iBAAsC,EACtC,KAAiC,EACjC,WAAyD,GAC1D,EAAE,cAAc,2CAiGhB"}
1
+ {"version":3,"file":"LoginForm.d.ts","sourceRoot":"","sources":["../src/LoginForm.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAA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'react';
10
10
  import { useAuth } from './useAuth';
11
+ const DefaultLink = ({ href, className, children }) => (_jsx("a", { href: href, className: className, children: children }));
11
12
  /**
12
13
  * Login form component with email/password authentication.
13
14
  * Uses Tailwind CSS utility classes for styling.
@@ -21,11 +22,22 @@ import { useAuth } from './useAuth';
21
22
  * />
22
23
  * ```
23
24
  */
24
- export function LoginForm({ onSuccess, onError, registerUrl = '/register', forgotPasswordUrl = '/forgot-password', title = 'Sign in to your account', description = 'Enter your email and password to continue', }) {
25
+ export function LoginForm({ onSuccess, onError, registerUrl = '/register', forgotPasswordUrl = '/forgot-password', title = 'Sign in to your account', description = 'Enter your email and password to continue', linkComponent: LinkComp = DefaultLink, labels = {}, }) {
25
26
  const { signIn, isLoading } = useAuth();
26
27
  const [email, setEmail] = useState('');
27
28
  const [password, setPassword] = useState('');
28
29
  const [error, setError] = useState(null);
30
+ const l = {
31
+ emailLabel: labels.emailLabel ?? 'Email',
32
+ emailPlaceholder: labels.emailPlaceholder ?? 'name@example.com',
33
+ passwordLabel: labels.passwordLabel ?? 'Password',
34
+ passwordPlaceholder: labels.passwordPlaceholder ?? 'Enter your password',
35
+ forgotPasswordText: labels.forgotPasswordText ?? 'Forgot password?',
36
+ submitButton: labels.submitButton ?? 'Sign In',
37
+ submittingButton: labels.submittingButton ?? 'Signing in...',
38
+ noAccountText: labels.noAccountText ?? "Don't have an account?",
39
+ signUpText: labels.signUpText ?? 'Sign up',
40
+ };
29
41
  const handleSubmit = async (e) => {
30
42
  e.preventDefault();
31
43
  setError(null);
@@ -39,5 +51,5 @@ export function LoginForm({ onSuccess, onError, registerUrl = '/register', forgo
39
51
  onError?.(authError);
40
52
  }
41
53
  };
42
- return (_jsxs("div", { className: "mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]", children: [_jsxs("div", { className: "flex flex-col space-y-2 text-center", children: [_jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: title }), _jsx("p", { className: "text-sm text-muted-foreground", children: description })] }), _jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [error && (_jsx("div", { className: "rounded-md bg-destructive/15 p-3 text-sm text-destructive", role: "alert", children: error })), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "login-email", className: "text-sm font-medium leading-none", children: "Email" }), _jsx("input", { id: "login-email", type: "email", placeholder: "name@example.com", value: email, onChange: (e) => setEmail(e.target.value), required: true, autoComplete: "email", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("label", { htmlFor: "login-password", className: "text-sm font-medium leading-none", children: "Password" }), forgotPasswordUrl && (_jsx("a", { href: forgotPasswordUrl, className: "text-sm text-primary underline-offset-4 hover:underline", children: "Forgot password?" }))] }), _jsx("input", { id: "login-password", type: "password", placeholder: "Enter your password", value: password, onChange: (e) => setPassword(e.target.value), required: true, autoComplete: "current-password", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsx("button", { type: "submit", disabled: isLoading, className: "inline-flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground ring-offset-background transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", children: isLoading ? 'Signing in...' : 'Sign In' })] }), registerUrl && (_jsxs("p", { className: "px-8 text-center text-sm text-muted-foreground", children: ["Don't have an account?", ' ', _jsx("a", { href: registerUrl, className: "text-primary underline-offset-4 hover:underline", children: "Sign up" })] }))] }));
54
+ return (_jsxs("div", { className: "mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[380px]", children: [_jsxs("div", { className: "flex flex-col space-y-2 text-center", children: [_jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: title }), _jsx("p", { className: "text-sm text-muted-foreground", children: description })] }), _jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [error && (_jsx("div", { className: "rounded-md bg-destructive/15 p-3 text-sm text-destructive", role: "alert", children: error })), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "login-email", className: "text-sm font-medium leading-none", children: l.emailLabel }), _jsx("input", { id: "login-email", type: "email", placeholder: l.emailPlaceholder, value: email, onChange: (e) => setEmail(e.target.value), required: true, autoComplete: "email", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("label", { htmlFor: "login-password", className: "text-sm font-medium leading-none", children: l.passwordLabel }), forgotPasswordUrl && (_jsx(LinkComp, { href: forgotPasswordUrl, className: "text-sm text-primary underline-offset-4 hover:underline", children: l.forgotPasswordText }))] }), _jsx("input", { id: "login-password", type: "password", placeholder: l.passwordPlaceholder, value: password, onChange: (e) => setPassword(e.target.value), required: true, autoComplete: "current-password", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsx("button", { type: "submit", disabled: isLoading, className: "inline-flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground ring-offset-background transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", children: isLoading ? l.submittingButton : l.submitButton })] }), registerUrl && (_jsxs("p", { className: "px-8 text-center text-sm text-muted-foreground", children: [l.noAccountText, ' ', _jsx(LinkComp, { href: registerUrl, className: "text-primary underline-offset-4 hover:underline", children: l.signUpText })] }))] }));
43
55
  }
@@ -5,6 +5,25 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import React from 'react';
9
+ import type { AuthLinkComponentProps } from './types';
10
+ /** Translatable labels for the RegisterForm */
11
+ export interface RegisterFormLabels {
12
+ nameLabel?: string;
13
+ namePlaceholder?: string;
14
+ emailLabel?: string;
15
+ emailPlaceholder?: string;
16
+ passwordLabel?: string;
17
+ passwordPlaceholder?: string;
18
+ confirmPasswordLabel?: string;
19
+ confirmPasswordPlaceholder?: string;
20
+ passwordMismatchError?: string;
21
+ passwordTooShortError?: string;
22
+ submitButton?: string;
23
+ submittingButton?: string;
24
+ hasAccountText?: string;
25
+ signInText?: string;
26
+ }
8
27
  export interface RegisterFormProps {
9
28
  /** Callback on successful registration */
10
29
  onSuccess?: () => void;
@@ -16,6 +35,10 @@ export interface RegisterFormProps {
16
35
  title?: string;
17
36
  /** Custom description */
18
37
  description?: string;
38
+ /** Custom link component for SPA navigation (e.g. React Router's Link) */
39
+ linkComponent?: React.ComponentType<AuthLinkComponentProps>;
40
+ /** Override default labels for i18n */
41
+ labels?: RegisterFormLabels;
19
42
  }
20
43
  /**
21
44
  * Registration form component with name, email, and password fields.
@@ -29,5 +52,5 @@ export interface RegisterFormProps {
29
52
  * />
30
53
  * ```
31
54
  */
32
- export declare function RegisterForm({ onSuccess, onError, loginUrl, title, description, }: RegisterFormProps): import("react/jsx-runtime").JSX.Element;
55
+ export declare function RegisterForm({ onSuccess, onError, loginUrl, title, description, linkComponent: LinkComp, labels, }: RegisterFormProps): import("react/jsx-runtime").JSX.Element;
33
56
  //# sourceMappingURL=RegisterForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RegisterForm.d.ts","sourceRoot":"","sources":["../src/RegisterForm.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,WAAW,iBAAiB;IAChC,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,qCAAqC;IACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,OAAO,EACP,QAAmB,EACnB,KAA2B,EAC3B,WAAqD,GACtD,EAAE,iBAAiB,2CAuInB"}
1
+ {"version":3,"file":"RegisterForm.d.ts","sourceRoot":"","sources":["../src/RegisterForm.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,+CAA+C;AAC/C,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,qCAAqC;IACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,sBAAsB,CAAC,CAAC;IAC5D,uCAAuC;IACvC,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,OAAO,EACP,QAAmB,EACnB,KAA2B,EAC3B,WAAqD,EACrD,aAAa,EAAE,QAAsB,EACrC,MAAW,GACZ,EAAE,iBAAiB,2CAwJnB"}
@@ -8,6 +8,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
8
  */
9
9
  import { useState } from 'react';
10
10
  import { useAuth } from './useAuth';
11
+ const DefaultLink = ({ href, className, children }) => (_jsx("a", { href: href, className: className, children: children }));
11
12
  /**
12
13
  * Registration form component with name, email, and password fields.
13
14
  * Uses Tailwind CSS utility classes for styling.
@@ -20,22 +21,38 @@ import { useAuth } from './useAuth';
20
21
  * />
21
22
  * ```
22
23
  */
23
- export function RegisterForm({ onSuccess, onError, loginUrl = '/login', title = 'Create an account', description = 'Enter your information to get started', }) {
24
+ export function RegisterForm({ onSuccess, onError, loginUrl = '/login', title = 'Create an account', description = 'Enter your information to get started', linkComponent: LinkComp = DefaultLink, labels = {}, }) {
24
25
  const { signUp, isLoading } = useAuth();
25
26
  const [name, setName] = useState('');
26
27
  const [email, setEmail] = useState('');
27
28
  const [password, setPassword] = useState('');
28
29
  const [confirmPassword, setConfirmPassword] = useState('');
29
30
  const [error, setError] = useState(null);
31
+ const l = {
32
+ nameLabel: labels.nameLabel ?? 'Name',
33
+ namePlaceholder: labels.namePlaceholder ?? 'John Doe',
34
+ emailLabel: labels.emailLabel ?? 'Email',
35
+ emailPlaceholder: labels.emailPlaceholder ?? 'name@example.com',
36
+ passwordLabel: labels.passwordLabel ?? 'Password',
37
+ passwordPlaceholder: labels.passwordPlaceholder ?? 'Create a password (min. 8 characters)',
38
+ confirmPasswordLabel: labels.confirmPasswordLabel ?? 'Confirm Password',
39
+ confirmPasswordPlaceholder: labels.confirmPasswordPlaceholder ?? 'Confirm your password',
40
+ passwordMismatchError: labels.passwordMismatchError ?? 'Passwords do not match',
41
+ passwordTooShortError: labels.passwordTooShortError ?? 'Password must be at least 8 characters',
42
+ submitButton: labels.submitButton ?? 'Create Account',
43
+ submittingButton: labels.submittingButton ?? 'Creating account...',
44
+ hasAccountText: labels.hasAccountText ?? 'Already have an account?',
45
+ signInText: labels.signInText ?? 'Sign in',
46
+ };
30
47
  const handleSubmit = async (e) => {
31
48
  e.preventDefault();
32
49
  setError(null);
33
50
  if (password !== confirmPassword) {
34
- setError('Passwords do not match');
51
+ setError(l.passwordMismatchError);
35
52
  return;
36
53
  }
37
54
  if (password.length < 8) {
38
- setError('Password must be at least 8 characters');
55
+ setError(l.passwordTooShortError);
39
56
  return;
40
57
  }
41
58
  try {
@@ -48,5 +65,5 @@ export function RegisterForm({ onSuccess, onError, loginUrl = '/login', title =
48
65
  onError?.(authError);
49
66
  }
50
67
  };
51
- return (_jsxs("div", { className: "mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]", children: [_jsxs("div", { className: "flex flex-col space-y-2 text-center", children: [_jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: title }), _jsx("p", { className: "text-sm text-muted-foreground", children: description })] }), _jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [error && (_jsx("div", { className: "rounded-md bg-destructive/15 p-3 text-sm text-destructive", role: "alert", children: error })), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "register-name", className: "text-sm font-medium leading-none", children: "Name" }), _jsx("input", { id: "register-name", type: "text", placeholder: "John Doe", value: name, onChange: (e) => setName(e.target.value), required: true, autoComplete: "name", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "register-email", className: "text-sm font-medium leading-none", children: "Email" }), _jsx("input", { id: "register-email", type: "email", placeholder: "name@example.com", value: email, onChange: (e) => setEmail(e.target.value), required: true, autoComplete: "email", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "register-password", className: "text-sm font-medium leading-none", children: "Password" }), _jsx("input", { id: "register-password", type: "password", placeholder: "Create a password (min. 8 characters)", value: password, onChange: (e) => setPassword(e.target.value), required: true, minLength: 8, autoComplete: "new-password", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "register-confirm-password", className: "text-sm font-medium leading-none", children: "Confirm Password" }), _jsx("input", { id: "register-confirm-password", type: "password", placeholder: "Confirm your password", value: confirmPassword, onChange: (e) => setConfirmPassword(e.target.value), required: true, minLength: 8, autoComplete: "new-password", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsx("button", { type: "submit", disabled: isLoading, className: "inline-flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground ring-offset-background transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", children: isLoading ? 'Creating account...' : 'Create Account' })] }), loginUrl && (_jsxs("p", { className: "px-8 text-center text-sm text-muted-foreground", children: ["Already have an account?", ' ', _jsx("a", { href: loginUrl, className: "text-primary underline-offset-4 hover:underline", children: "Sign in" })] }))] }));
68
+ return (_jsxs("div", { className: "mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[380px]", children: [_jsxs("div", { className: "flex flex-col space-y-2 text-center", children: [_jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: title }), _jsx("p", { className: "text-sm text-muted-foreground", children: description })] }), _jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [error && (_jsx("div", { className: "rounded-md bg-destructive/15 p-3 text-sm text-destructive", role: "alert", children: error })), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "register-name", className: "text-sm font-medium leading-none", children: l.nameLabel }), _jsx("input", { id: "register-name", type: "text", placeholder: l.namePlaceholder, value: name, onChange: (e) => setName(e.target.value), required: true, autoComplete: "name", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "register-email", className: "text-sm font-medium leading-none", children: l.emailLabel }), _jsx("input", { id: "register-email", type: "email", placeholder: l.emailPlaceholder, value: email, onChange: (e) => setEmail(e.target.value), required: true, autoComplete: "email", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "register-password", className: "text-sm font-medium leading-none", children: l.passwordLabel }), _jsx("input", { id: "register-password", type: "password", placeholder: l.passwordPlaceholder, value: password, onChange: (e) => setPassword(e.target.value), required: true, minLength: 8, autoComplete: "new-password", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "register-confirm-password", className: "text-sm font-medium leading-none", children: l.confirmPasswordLabel }), _jsx("input", { id: "register-confirm-password", type: "password", placeholder: l.confirmPasswordPlaceholder, value: confirmPassword, onChange: (e) => setConfirmPassword(e.target.value), required: true, minLength: 8, autoComplete: "new-password", disabled: isLoading, className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" })] }), _jsx("button", { type: "submit", disabled: isLoading, className: "inline-flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground ring-offset-background transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", children: isLoading ? l.submittingButton : l.submitButton })] }), loginUrl && (_jsxs("p", { className: "px-8 text-center text-sm text-muted-foreground", children: [l.hasAccountText, ' ', _jsx(LinkComp, { href: loginUrl, className: "text-primary underline-offset-4 hover:underline", children: l.signInText })] }))] }));
52
69
  }
@@ -15,7 +15,7 @@ import type { AuthClient, AuthClientConfig } from './types';
15
15
  *
16
16
  * @example
17
17
  * ```ts
18
- * const authClient = createAuthClient({ baseURL: '/api/auth' });
18
+ * const authClient = createAuthClient({ baseURL: '/api/v1/auth' });
19
19
  * const { user, session } = await authClient.signIn({ email, password });
20
20
  * ```
21
21
  */
@@ -14,7 +14,7 @@
14
14
  *
15
15
  * @example
16
16
  * ```ts
17
- * const authClient = createAuthClient({ baseURL: '/api/auth' });
17
+ * const authClient = createAuthClient({ baseURL: '/api/v1/auth' });
18
18
  * const { user, session } = await authClient.signIn({ email, password });
19
19
  * ```
20
20
  */
@@ -29,7 +29,7 @@ export interface AuthenticatedAdapterOptions {
29
29
  * import { ObjectStackAdapter } from '@object-ui/data-objectstack';
30
30
  * import { createAuthClient, createAuthenticatedFetch } from '@object-ui/auth';
31
31
  *
32
- * const authClient = createAuthClient({ baseURL: '/api/auth' });
32
+ * const authClient = createAuthClient({ baseURL: '/api/v1/auth' });
33
33
  * const authenticatedFetch = createAuthenticatedFetch(authClient);
34
34
  *
35
35
  * const adapter = new ObjectStackAdapter({
@@ -17,7 +17,7 @@
17
17
  * import { ObjectStackAdapter } from '@object-ui/data-objectstack';
18
18
  * import { createAuthClient, createAuthenticatedFetch } from '@object-ui/auth';
19
19
  *
20
- * const authClient = createAuthClient({ baseURL: '/api/auth' });
20
+ * const authClient = createAuthClient({ baseURL: '/api/v1/auth' });
21
21
  * const authenticatedFetch = createAuthenticatedFetch(authClient);
22
22
  *
23
23
  * const adapter = new ObjectStackAdapter({
package/dist/index.d.ts CHANGED
@@ -22,14 +22,14 @@
22
22
  export { AuthProvider, type AuthProviderProps } from './AuthProvider';
23
23
  export { useAuth } from './useAuth';
24
24
  export { AuthGuard, type AuthGuardProps } from './AuthGuard';
25
- export { LoginForm, type LoginFormProps } from './LoginForm';
26
- export { RegisterForm, type RegisterFormProps } from './RegisterForm';
27
- export { ForgotPasswordForm, type ForgotPasswordFormProps } from './ForgotPasswordForm';
25
+ export { LoginForm, type LoginFormProps, type LoginFormLabels } from './LoginForm';
26
+ export { RegisterForm, type RegisterFormProps, type RegisterFormLabels } from './RegisterForm';
27
+ export { ForgotPasswordForm, type ForgotPasswordFormProps, type ForgotPasswordFormLabels } from './ForgotPasswordForm';
28
28
  export { UserMenu, type UserMenuProps } from './UserMenu';
29
29
  export { PreviewBanner, type PreviewBannerProps } from './PreviewBanner';
30
30
  export { createAuthClient } from './createAuthClient';
31
31
  export { createAuthenticatedFetch, type AuthenticatedAdapterOptions } from './createAuthenticatedFetch';
32
32
  export { getUserInitials } from './types';
33
- export type { AuthUser, AuthSession, AuthState, AuthClient, AuthClientConfig, AuthProviderConfig, PreviewModeOptions, SignInCredentials, SignUpData, } from './types';
33
+ export type { AuthUser, AuthSession, AuthState, AuthClient, AuthClientConfig, AuthLinkComponentProps, AuthProviderConfig, PreviewModeOptions, SignInCredentials, SignUpData, } from './types';
34
34
  export type { AuthContextValue } from './AuthContext';
35
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAA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AAsB,CAAC;AACvH,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,KAAK,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C,YAAY,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,GACX,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
package/dist/types.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import type React from 'react';
8
9
  /**
9
10
  * Authentication types for @object-ui/auth
10
11
  */
@@ -67,7 +68,7 @@ export interface SignUpData {
67
68
  }
68
69
  /** Auth client configuration */
69
70
  export interface AuthClientConfig {
70
- /** Authentication server URL (e.g., "/api/auth") */
71
+ /** Authentication server URL (e.g., "/api/v1/auth") */
71
72
  baseURL: string;
72
73
  /** Custom fetch function for requests */
73
74
  fetchFn?: typeof fetch;
@@ -117,6 +118,15 @@ export interface PreviewModeOptions {
117
118
  /** Banner message displayed in the UI during preview mode */
118
119
  bannerMessage?: string;
119
120
  }
121
+ /** Props for custom link components used in auth forms (e.g. React Router's Link) */
122
+ export interface AuthLinkComponentProps {
123
+ /** Target URL */
124
+ href: string;
125
+ /** CSS class names */
126
+ className?: string;
127
+ /** Link content */
128
+ children: React.ReactNode;
129
+ }
120
130
  /** Auth provider configuration */
121
131
  export interface AuthProviderConfig {
122
132
  /** Authentication server URL */
@@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CAAC;IACnB,mBAAmB;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,kCAAkC;AAClC,MAAM,WAAW,kBAAkB;IACjC,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,uCAAuC;IACvC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAC/C,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/auth",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Authentication system for Object UI with AuthProvider, useAuth hook, AuthGuard, and form components.",
@@ -16,7 +16,8 @@
16
16
  "exports": {
17
17
  ".": {
18
18
  "types": "./dist/index.d.ts",
19
- "import": "./dist/index.js"
19
+ "import": "./dist/index.js",
20
+ "default": "./dist/index.js"
20
21
  }
21
22
  },
22
23
  "files": [
@@ -26,7 +27,7 @@
26
27
  "react": "^18.0.0 || ^19.0.0"
27
28
  },
28
29
  "dependencies": {
29
- "@object-ui/types": "3.1.0"
30
+ "@object-ui/types": "3.1.2"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@types/react": "19.2.14",