doct-ui-auth-kit 1.0.8 → 1.0.9

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.
Files changed (80) hide show
  1. package/package.json +3 -2
  2. package/dist/adapters/http-auth-adapter.d.ts +0 -8
  3. package/dist/adapters/index.d.ts +0 -1
  4. package/dist/auth/index.d.ts +0 -23
  5. package/dist/auth-methods/apple.d.ts +0 -19
  6. package/dist/auth-methods/google.d.ts +0 -5
  7. package/dist/auth-methods/index.d.ts +0 -2
  8. package/dist/auth-methods/use-google-auth.d.ts +0 -69
  9. package/dist/components/common/default-footer.d.ts +0 -5
  10. package/dist/components/common/enterprise-header.d.ts +0 -5
  11. package/dist/components/common/index.d.ts +0 -2
  12. package/dist/components/form/rhf-doct-phone-input.d.ts +0 -3
  13. package/dist/components/form/rhf-input-field.d.ts +0 -3
  14. package/dist/components/form/rhf-otp-input-field.d.ts +0 -3
  15. package/dist/components/layout/auth-layout-preset.d.ts +0 -30
  16. package/dist/components/layout/auth-layout-public.d.ts +0 -13
  17. package/dist/components/layout/auth-layout-wrapper.d.ts +0 -59
  18. package/dist/components/layout/auth-layout.d.ts +0 -89
  19. package/dist/components/layout/image-slider.d.ts +0 -28
  20. package/dist/components/layout/index.d.ts +0 -8
  21. package/dist/components/layout/main-layout.d.ts +0 -30
  22. package/dist/constants/demo-slider.d.ts +0 -14
  23. package/dist/constants/index.d.ts +0 -2
  24. package/dist/constants/layout-presets.d.ts +0 -6
  25. package/dist/core/auth-api-adapter.d.ts +0 -6
  26. package/dist/core/auth-context.d.ts +0 -17
  27. package/dist/core/auth-flow.d.ts +0 -5
  28. package/dist/core/auth-provider.d.ts +0 -8
  29. package/dist/core/auth-types.d.ts +0 -5
  30. package/dist/core/device-detection.d.ts +0 -15
  31. package/dist/core/index.d.ts +0 -11
  32. package/dist/core/sso-session.d.ts +0 -29
  33. package/dist/core/use-auth-flow.d.ts +0 -5
  34. package/dist/hooks/index.d.ts +0 -5
  35. package/dist/hooks/use-login-entry-form.d.ts +0 -12
  36. package/dist/hooks/use-main-auth-page-handlers.d.ts +0 -9
  37. package/dist/hooks/use-otp-verification.d.ts +0 -15
  38. package/dist/hooks/use-repeat-login.d.ts +0 -9
  39. package/dist/hooks/use-signup-form.d.ts +0 -12
  40. package/dist/index.d.ts +0 -11
  41. package/dist/pages/index.d.ts +0 -8
  42. package/dist/pages/login-entry/index.d.ts +0 -3
  43. package/dist/pages/login-entry/login-entry-page.d.ts +0 -21
  44. package/dist/pages/login-entry/login-entry.d.ts +0 -21
  45. package/dist/pages/main-login/index.d.ts +0 -3
  46. package/dist/pages/main-login/main-login-page.d.ts +0 -16
  47. package/dist/pages/main-login/main-login.d.ts +0 -25
  48. package/dist/pages/otp-verification/index.d.ts +0 -3
  49. package/dist/pages/otp-verification/otp-verification-page.d.ts +0 -23
  50. package/dist/pages/otp-verification/otp-verification.d.ts +0 -22
  51. package/dist/pages/repeat-login/index.d.ts +0 -3
  52. package/dist/pages/repeat-login/repeat-login-page.d.ts +0 -24
  53. package/dist/pages/repeat-login/repeat-login.d.ts +0 -25
  54. package/dist/pages/signup/index.d.ts +0 -3
  55. package/dist/pages/signup/signup-page.d.ts +0 -6
  56. package/dist/pages/signup/signup.d.ts +0 -7
  57. package/dist/types/auth/auth-api-adapter.d.ts +0 -39
  58. package/dist/types/auth/auth-provider.d.ts +0 -40
  59. package/dist/types/auth/auth-types.d.ts +0 -70
  60. package/dist/types/auth/device-detection.d.ts +0 -10
  61. package/dist/types/auth/flow.d.ts +0 -122
  62. package/dist/types/auth/index.d.ts +0 -9
  63. package/dist/types/auth/sso-session.d.ts +0 -33
  64. package/dist/types/components/auth-layout-types.d.ts +0 -94
  65. package/dist/types/components/forms.d.ts +0 -68
  66. package/dist/types/components/index.d.ts +0 -7
  67. package/dist/types/components/layout-presets.d.ts +0 -24
  68. package/dist/types/components/layout.d.ts +0 -57
  69. package/dist/types/index.d.ts +0 -7
  70. package/dist/types/pages/index.d.ts +0 -9
  71. package/dist/types/pages/login-form.d.ts +0 -56
  72. package/dist/types/pages/main-login.d.ts +0 -40
  73. package/dist/types/pages/otp-verification.d.ts +0 -40
  74. package/dist/types/pages/pages.d.ts +0 -133
  75. package/dist/types/pages/repeat-login.d.ts +0 -29
  76. package/dist/types/pages/signup-form.d.ts +0 -48
  77. package/dist/utils/index.d.ts +0 -4
  78. package/dist/utils/set-form-errors-from-zod.d.ts +0 -11
  79. package/dist/validations/index.d.ts +0 -6
  80. package/dist/validations/schemas.d.ts +0 -73
@@ -1,94 +0,0 @@
1
- import { ReactNode } from 'react';
2
- /**
3
- * Layout configuration types
4
- */
5
- export type AuthLayoutVariant = 'mobile' | 'desktop';
6
- export type AuthLayoutMaxWidth = 'sm' | 'md' | 'lg';
7
- /** Text/alignment variant for Logo, Title, Description slots */
8
- export type AuthLayoutAlign = 'left' | 'center' | 'right';
9
- /**
10
- * Props for AuthLayout.Root component
11
- */
12
- export interface AuthLayoutRootProps {
13
- /** Main content (compound components) */
14
- children: ReactNode;
15
- /** Layout variation for spacing and alignment */
16
- variant?: AuthLayoutVariant;
17
- /** Maximum width constraint for the content area */
18
- maxWidth?: AuthLayoutMaxWidth;
19
- /** Additional className for the root container */
20
- className?: string;
21
- /** Additional className for the content wrapper */
22
- contentClassName?: string;
23
- }
24
- /**
25
- * Props for AuthLayout.Header component
26
- */
27
- export interface AuthLayoutHeaderProps {
28
- /** Header content */
29
- children: ReactNode;
30
- /** Additional className */
31
- className?: string;
32
- }
33
- /**
34
- * Props for AuthLayout.Logo component
35
- */
36
- export interface AuthLayoutLogoProps {
37
- /** Logo content */
38
- children: ReactNode;
39
- /** Alignment: left, center (default), or right */
40
- align?: AuthLayoutAlign;
41
- /** Additional className */
42
- className?: string;
43
- }
44
- /**
45
- * Props for AuthLayout.Title component
46
- */
47
- export interface AuthLayoutTitleProps {
48
- /** Title content */
49
- children: ReactNode;
50
- /** Alignment: left, center (default), or right */
51
- align?: AuthLayoutAlign;
52
- /** Additional className */
53
- className?: string;
54
- }
55
- /**
56
- * Props for AuthLayout.Description component
57
- */
58
- export interface AuthLayoutDescriptionProps {
59
- /** Description content */
60
- children: ReactNode;
61
- /** Alignment: left, center (default), or right */
62
- align?: AuthLayoutAlign;
63
- /** Additional className */
64
- className?: string;
65
- }
66
- /**
67
- * Props for AuthLayout.Body component
68
- */
69
- export interface AuthLayoutBodyProps {
70
- /** Body content (forms, buttons, etc.) */
71
- children: ReactNode;
72
- /** Additional className */
73
- className?: string;
74
- }
75
- /**
76
- * Props for AuthLayout.Main component
77
- */
78
- export interface AuthLayoutMainProps {
79
- /** Main content (Logo, Title, Description, Body slots) */
80
- children: ReactNode;
81
- /** When true, constrains main content width to 320px (max-w-[320px]) */
82
- sm?: boolean;
83
- /** Additional className */
84
- className?: string;
85
- }
86
- /**
87
- * Props for AuthLayout.Footer component
88
- */
89
- export interface AuthLayoutFooterProps {
90
- /** Footer content */
91
- children: ReactNode;
92
- /** Additional className */
93
- className?: string;
94
- }
@@ -1,68 +0,0 @@
1
- import { KeyboardEvent } from 'react';
2
- import { Control, FieldValues } from 'react-hook-form';
3
- /** Base props shared by RHF form field components. */
4
- export interface BaseFormFieldProps {
5
- /** Field name used by react-hook-form for registration and validation. */
6
- name: string;
7
- /** Visible label rendered above or beside the input. */
8
- label?: string;
9
- /** Placeholder text shown when the input is empty. */
10
- placeholder?: string;
11
- /** Whether the field is required for form submission. */
12
- required?: boolean;
13
- /** Whether the field is disabled (non-interactive). */
14
- disabled?: boolean;
15
- /** Additional CSS class name(s) applied to the field wrapper. */
16
- className?: string;
17
- /** Validation error message to display below the input. */
18
- error?: string;
19
- /** Supplementary helper text shown below the input when there is no error. */
20
- helperText?: string;
21
- /** Focus this field when form/screen opens (PRODUCT_PROTOCOLS #26). */
22
- autoFocus?: boolean;
23
- }
24
- /** Props for the text/email/number input field component. */
25
- export interface RHFInputFieldProps extends BaseFormFieldProps {
26
- /** HTML input type. Allowed: `'text'`, `'email'`, `'password'`, `'number'`, `'tel'`, `'url'`, `'search'`. */
27
- type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'search';
28
- /** HTML `autocomplete` attribute value (e.g. `'email'`, `'tel'`). */
29
- autoComplete?: string;
30
- /** Maximum character length enforced on the input. */
31
- maxLength?: number;
32
- /** Minimum character length enforced on the input. */
33
- minLength?: number;
34
- /** Regex pattern string for native HTML validation. */
35
- pattern?: string;
36
- /** react-hook-form `Control` instance. When omitted, the field uses the nearest `FormProvider`. */
37
- control?: Control<FieldValues>;
38
- /** Called when a key is pressed while the input is focused. */
39
- onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
40
- /** When true, restricts input to numeric characters only. */
41
- numericOnly?: boolean;
42
- }
43
- /** Props for RHF wrapper around DoctPhoneInput (docthub-core-components). */
44
- export interface RHFDoctPhoneInputFieldProps extends BaseFormFieldProps {
45
- /** ISO 3166-1 alpha-2 country code pre-selected in the phone input (e.g. `'IN'`, `'US'`). */
46
- defaultCountry?: string;
47
- /** Display variant: `'default'` shows full country selector, `'flag'` shows flag icon only. */
48
- variant?: 'default' | 'flag';
49
- /** react-hook-form `Control` instance. When omitted, the field uses the nearest `FormProvider`. */
50
- control?: Control<FieldValues>;
51
- }
52
- /** Props for the OTP input field component. */
53
- export interface RHFOtpInputFieldProps extends BaseFormFieldProps {
54
- /** Number of OTP digit boxes to render. @default 6 */
55
- length?: number;
56
- /** Input type for each OTP box: `'text'`, `'number'`, or `'password'` (masked). */
57
- type?: 'text' | 'number' | 'password';
58
- /** Focus the first OTP box on mount. */
59
- autoFocus?: boolean;
60
- /** Automatically trigger submission when all boxes are filled. */
61
- autoSubmit?: boolean;
62
- /** Called with the complete OTP string once all boxes are filled. */
63
- onComplete?: (otp: string) => void;
64
- /** CSS class name(s) applied to each individual OTP input box. */
65
- inputClassName?: string;
66
- /** react-hook-form `Control` instance. When omitted, the field uses the nearest `FormProvider`. */
67
- control?: Control<FieldValues>;
68
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Component prop types: form fields, layouts, auth-layout compound, presets.
3
- */
4
- export * from './forms';
5
- export * from './layout';
6
- export * from './auth-layout-types';
7
- export * from './layout-presets';
@@ -1,24 +0,0 @@
1
- import { AuthLayoutAlign, AuthLayoutMaxWidth, AuthLayoutVariant } from './auth-layout-types';
2
- /** Layout type: two-panel with slider vs single centered column. */
3
- export type LayoutType = 'withSlider' | 'standalone';
4
- /**
5
- * Named presets for auth screens. Kept minimal to avoid preset explosion.
6
- * Add new presets only for distinct layout structures, not for auth methods.
7
- */
8
- export type LayoutPresetName = 'login' | 'signup' | 'verification' | '';
9
- /**
10
- * Structure-only config derived from a preset.
11
- * Used by AuthLayout to render the correct shell (slider, width, alignment).
12
- */
13
- export interface LayoutPresetConfig {
14
- /** Whether to show the two-panel slider (e.g. login) or standalone column. */
15
- layoutType: LayoutType;
16
- /** Mobile vs desktop spacing/breakpoints. */
17
- variant: AuthLayoutVariant;
18
- /** Max width of the content area. */
19
- maxWidth: AuthLayoutMaxWidth;
20
- /** Constrain main content to 320px when 'sm'. */
21
- contentWidth: 'sm' | 'default';
22
- /** Title/description alignment. */
23
- align: AuthLayoutAlign;
24
- }
@@ -1,57 +0,0 @@
1
- import { ReactNode } from 'react';
2
- /** Props for the ImageSlider component. */
3
- export interface ImageSliderProps {
4
- /** Array of image URLs to display */
5
- images: string[];
6
- /** Auto-play interval in milliseconds (0 to disable) */
7
- autoPlayInterval?: number;
8
- /** Additional className for the root container */
9
- className?: string;
10
- /** Whether to hide the built-in slider indicators */
11
- hideIndicators?: boolean;
12
- /** Optional callback fired whenever the active slide changes */
13
- onSlideChange?: (index: number) => void;
14
- /** Controlled active index (makes component controlled) */
15
- activeIndex?: number;
16
- /** Callback for manual slide navigation in controlled mode */
17
- onNavigate?: (index: number) => void;
18
- }
19
- /**
20
- * Props for the MainLayout component.
21
- * Two-panel auth page: left panel (marketing/slider), right panel (auth content).
22
- */
23
- export interface MainLayoutProps {
24
- /** Array of image URLs for the slider */
25
- sliderImages?: string[];
26
- /** Auto-play interval for slider in milliseconds (0 to disable) */
27
- sliderAutoPlayInterval?: number;
28
- /** Call-to-action text displayed above the image card. Set to null to hide */
29
- ctaText?: ReactNode | null;
30
- /** Per-slide title/CTA (overrides ctaText when provided; uses active slide index) */
31
- sliderTitles?: (ReactNode | string)[] | undefined;
32
- /** Additional className for the root container */
33
- className?: string;
34
- /** Additional className for the marketing panel (left side) */
35
- marketingClassName?: string;
36
- /** Additional className for the content panel (right side) */
37
- contentClassName?: string;
38
- /** Main authentication content (typically AuthLayout.Root with slots) */
39
- children: ReactNode;
40
- }
41
- /** Props for the MarketingPanel component (left side). */
42
- export interface MarketingPanelProps {
43
- /** Array of image URLs for the slider */
44
- sliderImages: string[];
45
- /** Auto-play interval for slider in milliseconds */
46
- sliderAutoPlayInterval: number;
47
- /** Active slide index (controlled) */
48
- activeSlideIndex: number;
49
- /** Callback when slide changes */
50
- onSlideChange: (index: number) => void;
51
- /** Call-to-action text */
52
- ctaText?: ReactNode | null;
53
- /** Per-slide title/CTA (overrides ctaText when provided) */
54
- sliderTitles?: (ReactNode | string)[] | undefined;
55
- /** Additional className */
56
- className?: string;
57
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Central export for all types and interfaces.
3
- * Organized by domain: auth (SSO), components (props), pages (page-specific).
4
- */
5
- export * from './auth';
6
- export * from './components';
7
- export * from './pages';
@@ -1,9 +0,0 @@
1
- /**
2
- * Page-specific types: props, form values, hook options/return types.
3
- */
4
- export * from './pages';
5
- export * from './login-form';
6
- export * from './signup-form';
7
- export * from './otp-verification';
8
- export * from './main-login';
9
- export * from './repeat-login';
@@ -1,56 +0,0 @@
1
- import { UseFormReturn } from 'react-hook-form';
2
- import { z } from 'zod';
3
- import { loginEmailFormSchema, loginPhoneFormSchema } from '../../validations';
4
- /** Login mode: phone number or email */
5
- export type LoginEntryMode = 'phone' | 'email';
6
- /** Form values for phone-based login, inferred from the Zod schema. */
7
- export type PhoneFormValues = z.infer<typeof loginPhoneFormSchema>;
8
- /** Form values for email-based login, inferred from the Zod schema. */
9
- export type EmailFormValues = z.infer<typeof loginEmailFormSchema>;
10
- /** Discriminated union of phone or email login form values. */
11
- export type LoginEntryFormValues = PhoneFormValues | EmailFormValues;
12
- /** Payload when login entry form is valid (phone or email). */
13
- export type LoginEntrySubmitData = {
14
- phone?: string;
15
- email?: string;
16
- };
17
- /**
18
- * Params passed to onSuccess after submitApi resolves.
19
- * Lets the consumer redirect to OTP with mode and recipient (for recipientDisplay) without storing them in refs.
20
- */
21
- export interface LoginEntrySuccessParams {
22
- /** Current login entry mode (phone or email). */
23
- mode: LoginEntryMode;
24
- /** Submitted phone or email string; use for OTP page recipientDisplay or verify API. */
25
- recipient: string;
26
- }
27
- export interface UseLoginEntryFormOptions {
28
- mode: LoginEntryMode;
29
- /**
30
- * Sync callback with valid form data. Used when parent owns API (e.g. AuthFlow passes actions.submitIdentifier).
31
- * Ignored when submitApi is provided.
32
- */
33
- onSubmit?: ((data: LoginEntrySubmitData) => void) | undefined;
34
- /**
35
- * When provided, hook runs business logic: validate → call submitApi(data) → onSuccess(params).
36
- * Use from consumer (e.g. Next.js): submitApi = sendOtp, onSuccess = (params) => router.push(`/otp?mode=${params.mode}&recipient=${encodeURIComponent(params.recipient)}`).
37
- */
38
- submitApi?: ((data: LoginEntrySubmitData) => Promise<void>) | undefined;
39
- /** Called after submitApi resolves successfully; receives mode and recipient for OTP redirect/display. */
40
- onSuccess?: ((params: LoginEntrySuccessParams) => void) | undefined;
41
- /** Called when submitApi rejects or throws. */
42
- onError?: ((error: unknown) => void) | undefined;
43
- }
44
- /** Return value of the `useLoginEntryForm` hook, providing form state and mode info. */
45
- export interface UseLoginEntryFormReturn {
46
- /** react-hook-form methods bound to the current login mode's schema. */
47
- methods: UseFormReturn<LoginEntryFormValues>;
48
- /** Submit handler to pass to the form's `onSubmit`. Validates and dispatches the login data. */
49
- handleSubmit: (data: LoginEntryFormValues) => void;
50
- /** True when the current mode is `'phone'`; use for conditional field rendering. */
51
- isPhone: boolean;
52
- /** True when current form values pass validation (for disabling Continue until valid – edge cases 3, 4). */
53
- isFormValid: (data: LoginEntryFormValues) => boolean;
54
- /** True while submitApi is in flight. Use to disable Continue button and show loading. */
55
- isSubmitting: boolean;
56
- }
@@ -1,40 +0,0 @@
1
- /** Handlers exposed by the main auth page (method select). */
2
- export interface MainAuthPageHandlers {
3
- /** Called when the user selects "Continue with Mobile". */
4
- onContinueWithMobile: () => void;
5
- /** Called when the user selects "Continue with Email". */
6
- onContinueWithEmail: () => void;
7
- /** Called when the user selects "Continue with Google". */
8
- onContinueWithGoogle: () => void;
9
- /** Called when the user selects "Continue with Apple". */
10
- onContinueWithApple: () => void;
11
- }
12
- /** Config for lib-handled Google sign-in. When set, the lib runs the OAuth flow and calls onCredential. */
13
- export interface MainLoginGoogleProviderConfig {
14
- /** Google OAuth 2.0 client ID. */
15
- clientId: string;
16
- /** Called with ID token (One Tap) or auth code (button popup). Send to your backend to verify. */
17
- onCredential: (credential: string) => void;
18
- /** Enable Google One Tap prompt for automatic sign-in. */
19
- enableOneTap?: boolean;
20
- }
21
- /** Config for lib-handled Apple sign-in (stub). When set, the lib will run the flow and call onCredential when implemented. */
22
- export interface MainLoginAppleProviderConfig {
23
- /** Apple Services ID (client ID) configured in the Apple Developer portal. */
24
- clientId: string;
25
- /** OAuth redirect URI registered with Apple for the sign-in flow. */
26
- redirectUri: string;
27
- /** Called with the Apple identity token after a successful sign-in. Send to your backend to verify. */
28
- onCredential: (credential: string) => void;
29
- }
30
- /** Optional provider config so the lib handles Google/Apple API calls. */
31
- export interface MainLoginPageProvidersConfig {
32
- /** Google sign-in configuration. When set, the lib handles the Google OAuth flow. */
33
- google?: MainLoginGoogleProviderConfig;
34
- /** Apple sign-in configuration. When set, the lib handles the Apple OAuth flow. */
35
- apple?: MainLoginAppleProviderConfig;
36
- }
37
- /** Options for useMainAuthPageHandlers: optional callback overrides + optional provider config for lib-handled OAuth. */
38
- export type UseMainAuthPageHandlersOptions = Partial<MainAuthPageHandlers> & {
39
- providers?: MainLoginPageProvidersConfig;
40
- };
@@ -1,40 +0,0 @@
1
- import { UseFormReturn } from 'react-hook-form';
2
- import { z } from 'zod';
3
- import { OtpVerificationMode, otpFormSchema } from '../../validations';
4
- export type { OtpVerificationMode };
5
- /** Form values for the OTP verification form, inferred from the Zod schema. */
6
- export type OtpFormValues = z.infer<typeof otpFormSchema>;
7
- /** Options for the `useOtpVerification` hook controlling mode, submission, and callbacks. */
8
- export interface UseOtpVerificationOptions {
9
- /** OTP mode: phone (60s cooldown) or email (2 min cooldown). */
10
- mode: OtpVerificationMode;
11
- /** Sync callback with OTP string. Use when parent owns API (e.g. AuthFlow). Ignored when submitApi is provided. */
12
- onSubmit?: ((otp: string) => void) | undefined;
13
- /** Called when the user requests a new OTP code (resend). Ignored when submitApi is provided. */
14
- onResendCode?: (() => void) | undefined;
15
- /** When provided, hook runs: validate → submitApi(otp) → onSuccess(). Consumer passes redirect in onSuccess. */
16
- submitApi?: ((otp: string) => Promise<void>) | undefined;
17
- /** Called after submitApi resolves (e.g. router.push('/dashboard')). */
18
- onSuccess?: (() => void) | undefined;
19
- /** Called when submitApi rejects or throws. */
20
- onError?: ((error: unknown) => void) | undefined;
21
- }
22
- /** Return value of the `useOtpVerification` hook, providing form state and resend controls. */
23
- export interface UseOtpVerificationReturn {
24
- /** react-hook-form methods bound to the OTP form. */
25
- methods: UseFormReturn<OtpFormValues>;
26
- /** Submit handler to pass to the form's `onSubmit`. Validates and dispatches the OTP. */
27
- handleSubmit: (data: OtpFormValues) => void;
28
- /** True when current form values pass validation (for disabling Submit until valid – edge case 6). */
29
- isFormValid: (data: OtpFormValues) => boolean;
30
- /** Triggers a resend of the OTP code and resets the cooldown timer. */
31
- handleResend: () => void;
32
- /** Seconds remaining before the user can request another OTP code. */
33
- resendSecondsLeft: number;
34
- /** True when the resend cooldown has elapsed and the user may request a new code. */
35
- canResend: boolean;
36
- /** Human-readable countdown string (e.g. `"00:45"`) for display next to the resend button. */
37
- timerText: string;
38
- /** True while submitApi is in flight. */
39
- isSubmitting: boolean;
40
- }
@@ -1,133 +0,0 @@
1
- import { UserType } from '../auth/auth-types';
2
- import { IdentifierType } from '../auth/flow';
3
- import { LoginEntryMode } from './login-form';
4
- import { UseMainAuthPageHandlersOptions } from './main-login';
5
- import { OtpVerificationMode } from './otp-verification';
6
- /** Props for MainLoginPage and MainLogin components. */
7
- export type MainLoginPageProps = UseMainAuthPageHandlersOptions;
8
- /** Props for LoginEntry (inner form without layout). */
9
- export interface LoginEntryProps {
10
- /** Mode: phone number or email input */
11
- mode: LoginEntryMode;
12
- /** Override title (consumers render via AuthLayout.Title) */
13
- title?: string;
14
- /** Override subtitle (consumers render via AuthLayout.Description) */
15
- subtitle?: string;
16
- /** Handler when back button is clicked (consumers render back button in AuthLayout.Logo) */
17
- onBack?: () => void;
18
- /**
19
- * Sync callback with valid data. Use when parent owns API (e.g. AuthFlow).
20
- * Ignored when submitApi is provided.
21
- */
22
- onSubmit?: ((data: {
23
- phone?: string;
24
- email?: string;
25
- }) => void) | undefined;
26
- /**
27
- * Async API call (e.g. send OTP). When provided, hook runs: validate → submitApi(data) → onSuccess().
28
- * Consumer (e.g. Next.js) can pass redirect in onSuccess.
29
- */
30
- submitApi?: ((data: {
31
- phone?: string;
32
- email?: string;
33
- }) => Promise<void>) | undefined;
34
- /** Called after submitApi succeeds; receives { mode, recipient } for OTP redirect/recipientDisplay. */
35
- onSuccess?: ((params: {
36
- mode: LoginEntryMode;
37
- recipient: string;
38
- }) => void) | undefined;
39
- /** Called when submitApi fails. */
40
- onError?: ((error: unknown) => void) | undefined;
41
- }
42
- /** Props for the full LoginEntryPage (adds optional layout overrides for story/viewport). */
43
- export interface LoginEntryPageProps extends LoginEntryProps {
44
- /** Layout type. Default: 'withSlider' for desktop, use 'standalone' for mobile. */
45
- layoutType?: 'withSlider' | 'standalone';
46
- /** Layout variant. Default derived from layoutType if not set. */
47
- variant?: 'desktop' | 'mobile';
48
- }
49
- /** Props for Signup (inner form without layout). */
50
- export interface SignupPageProps {
51
- /** Indian: which field to collect. Foreign: use 'foreign' mode (name + email + phone). */
52
- userType: UserType;
53
- /** How user started (phone or email). */
54
- loginMethod: IdentifierType;
55
- /** Indian only: which field to collect (phone or email). */
56
- signupCollectField: IdentifierType;
57
- /** Foreign only: phone when user entered phone before signup details. */
58
- pendingPhone?: string | undefined;
59
- /** Sync callback with valid data. Use when parent owns API (e.g. AuthFlow). Ignored when submitApi is provided. */
60
- onSubmit?: ((data: {
61
- fullName: string;
62
- phone?: string;
63
- email?: string;
64
- }) => void) | undefined;
65
- /** Async API (e.g. complete profile). When provided, hook runs: validate → submitApi(data) → onSuccess(). */
66
- submitApi?: ((data: {
67
- fullName: string;
68
- phone?: string;
69
- email?: string;
70
- }) => Promise<void>) | undefined;
71
- /** Called after submitApi succeeds (e.g. router.push('/otp') or next step). */
72
- onSuccess?: (() => void) | undefined;
73
- /** Called when submitApi fails. */
74
- onError?: ((error: unknown) => void) | undefined;
75
- }
76
- /** Props for the full SignupPage (adds optional layout overrides). */
77
- export interface SignupPageFullProps extends SignupPageProps {
78
- layoutType?: 'withSlider' | 'standalone';
79
- variant?: 'desktop' | 'mobile';
80
- }
81
- /** Props for OtpVerification (inner form without layout). */
82
- export interface OtpVerificationProps {
83
- /** Mode: mobile (phone) or email OTP */
84
- mode: OtpVerificationMode;
85
- /** Title override. Default: "6 digit OTP has been sent to your Mobile" | "..." Email */
86
- title?: string | undefined;
87
- /** Masked phone (e.g. "+91 9825910X0X") or email (e.g. "j***@gmail.com") */
88
- recipientDisplay: string;
89
- /** When true, show instruction line ("Kindly check your Email Inbox."). Used for foreign user flow. */
90
- isForeignUser?: boolean | undefined;
91
- /** Handler when back is clicked */
92
- onBack?: (() => void) | undefined;
93
- /** Sync callback with OTP. Use when parent owns API (e.g. AuthFlow). Ignored when submitApi is provided. */
94
- onSubmit?: ((otp: string) => void) | undefined;
95
- /** Handler when user requests resend code */
96
- onResendCode?: (() => void) | undefined;
97
- /** Async API (e.g. verify OTP). When provided, hook runs: validate → submitApi(otp) → onSuccess(). */
98
- submitApi?: ((otp: string) => Promise<void>) | undefined;
99
- /** Called after submitApi succeeds (e.g. router.push('/dashboard')). */
100
- onSuccess?: (() => void) | undefined;
101
- /** Called when submitApi fails. */
102
- onError?: ((error: unknown) => void) | undefined;
103
- }
104
- /** Props for the full OtpVerificationPage (adds optional layout overrides). */
105
- export interface OtpVerificationPageProps extends OtpVerificationProps {
106
- layoutType?: 'withSlider' | 'standalone';
107
- variant?: 'desktop' | 'mobile';
108
- }
109
- /** Props for RepeatLogin (inner component without layout). */
110
- export interface RepeatLoginProps {
111
- /**
112
- * Last used authentication method shown in the primary button label.
113
- * Example: "Mobile", "Email".
114
- *
115
- * @default "Mobile"
116
- */
117
- lastUsedMethod?: string;
118
- /** Sync handler for primary action. Use when caller owns API (e.g. AuthFlow). Ignored when continueApi is provided. */
119
- onContinueWithLastMethod?: (() => void) | undefined;
120
- /** Handler for the secondary action (choose another method). */
121
- onUseAnotherMethod?: (() => void) | undefined;
122
- /** Async API for continue (e.g. validate session). When provided, hook runs: continueApi() → onSuccess(). */
123
- continueApi?: (() => Promise<void>) | undefined;
124
- /** Called after continueApi succeeds (e.g. router.push('/dashboard')). */
125
- onSuccess?: (() => void) | undefined;
126
- /** Called when continueApi fails. */
127
- onError?: ((error: unknown) => void) | undefined;
128
- }
129
- /** Props for the full RepeatLoginPage (adds optional layout overrides). */
130
- export interface RepeatLoginPageProps extends RepeatLoginProps {
131
- layoutType?: 'withSlider' | 'standalone';
132
- variant?: 'desktop' | 'mobile';
133
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * Hook options and return type for repeat login (continue with last method).
3
- */
4
- export interface UseRepeatLoginOptions {
5
- /**
6
- * Last used authentication method shown in the primary button label.
7
- * @default "Mobile"
8
- */
9
- lastUsedMethod?: string | undefined;
10
- /** Sync handler for primary action. Use when caller owns API (e.g. AuthFlow). Ignored when continueApi is provided. */
11
- onContinueWithLastMethod?: (() => void) | undefined;
12
- /** Handler for the secondary action (choose another method). */
13
- onUseAnotherMethod?: (() => void) | undefined;
14
- /** Async API for continue (e.g. validate session). When provided, hook runs: continueApi() → onSuccess(). */
15
- continueApi?: (() => Promise<void>) | undefined;
16
- /** Called after continueApi succeeds (e.g. router.push('/dashboard')). */
17
- onSuccess?: (() => void) | undefined;
18
- /** Called when continueApi fails. */
19
- onError?: ((error: unknown) => void) | undefined;
20
- }
21
- /** Return value of the `useRepeatLogin` hook, providing continue handler and display state. */
22
- export interface UseRepeatLoginReturn {
23
- /** Call this when the user clicks "Continue with {lastUsedMethod}". */
24
- handleContinue: () => void;
25
- /** True while continueApi is in flight. */
26
- isSubmitting: boolean;
27
- /** Resolved lastUsedMethod for display (default "Mobile"). */
28
- lastUsedMethod: string;
29
- }
@@ -1,48 +0,0 @@
1
- import { UseFormReturn } from 'react-hook-form';
2
- import { z } from 'zod';
3
- import { signupEmailFormSchema, signupForeignFormSchema, signupPhoneFormSchema } from '../../validations';
4
- /** Signup mode: phone, email as second field, or foreign (full name + email + phone). */
5
- export type SignupEntryMode = 'phone' | 'email' | 'foreign';
6
- /** Form values for phone-based signup, inferred from the Zod schema. */
7
- export type SignupPhoneFormValues = z.infer<typeof signupPhoneFormSchema>;
8
- /** Form values for email-based signup, inferred from the Zod schema. */
9
- export type SignupEmailFormValues = z.infer<typeof signupEmailFormSchema>;
10
- /** Form values for foreign signup (full name + email + phone), inferred from the Zod schema. */
11
- export type SignupForeignFormValues = z.infer<typeof signupForeignFormSchema>;
12
- /** Discriminated union of all signup form value shapes. */
13
- export type SignupFormValues = SignupPhoneFormValues | SignupEmailFormValues | SignupForeignFormValues;
14
- /** Payload when signup form is valid. */
15
- export type SignupSubmitData = {
16
- fullName: string;
17
- phone?: string;
18
- email?: string;
19
- };
20
- export interface UseSignupFormOptions {
21
- /** Mode: phone, email as second field, or foreign (name + email + phone) */
22
- mode: SignupEntryMode;
23
- /** For foreign mode: pre-fill phone when user already entered it. */
24
- defaultPhone?: string | undefined;
25
- /** Sync callback with valid data. Use when parent owns API (e.g. AuthFlow). Ignored when submitApi is provided. */
26
- onSubmit?: ((data: SignupSubmitData) => void) | undefined;
27
- /** When provided, hook runs: validate → submitApi(data) → onSuccess(). Consumer passes redirect in onSuccess. */
28
- submitApi?: ((data: SignupSubmitData) => Promise<void>) | undefined;
29
- /** Called after submitApi succeeds (e.g. router.push('/otp') or next step). */
30
- onSuccess?: (() => void) | undefined;
31
- /** Called when submitApi rejects or throws. */
32
- onError?: ((error: unknown) => void) | undefined;
33
- }
34
- /** Return value of the `useSignupForm` hook, providing form state and mode flags. */
35
- export interface UseSignupFormReturn {
36
- /** react-hook-form methods bound to the current signup mode's schema. */
37
- methods: UseFormReturn<SignupFormValues>;
38
- /** Submit handler to pass to the form's `onSubmit`. Validates and dispatches signup data. */
39
- handleSubmit: (data: SignupFormValues) => void;
40
- /** True when mode is 'phone', false when mode is 'email'. For 'foreign' same as (mode === 'phone') for layout. */
41
- isPhone: boolean;
42
- /** True when mode is 'foreign' (full name + email + phone). */
43
- isForeign: boolean;
44
- /** True when current form values pass validation (for disabling Continue – edge cases 9, 16, 19). */
45
- isFormValid: (data: SignupFormValues) => boolean;
46
- /** True while submitApi is in flight. */
47
- isSubmitting: boolean;
48
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Reusable utilities used in 2+ places across the auth SDK.
3
- */
4
- export { setFormErrorsFromZod } from './set-form-errors-from-zod';
@@ -1,11 +0,0 @@
1
- import { ZodError } from 'zod';
2
- /**
3
- * Applies Zod validation errors to a React Hook Form setError function.
4
- * Used by form submit handlers to display field-level errors from schema validation.
5
- *
6
- * @param error - The ZodError from schema.safeParse when validation fails
7
- * @param setError - RHF's setError (e.g. methods.setError)
8
- */
9
- export declare function setFormErrorsFromZod(error: ZodError, setError: (path: string, opts: {
10
- message: string;
11
- }) => void): void;
@@ -1,6 +0,0 @@
1
- /**
2
- * Central export for all validation schemas and helpers.
3
- * Import from here: import { signupSchemas, loginSchemas, otpFormSchema } from '@/validations';
4
- */
5
- export type { OtpVerificationMode } from './schemas';
6
- export { capitalizeWords, emailSchema, fullNameSchema, getResendCooldownSeconds, loginEmailFormSchema, loginPhoneFormSchema, loginSchemas, OTP_LENGTH, otpFormSchema, phoneSchema, RESEND_COOLDOWN_EMAIL_SECONDS, RESEND_COOLDOWN_PHONE_SECONDS, signupEmailFormSchema, signupForeignFormSchema, signupPhoneFormSchema, signupSchemas, } from './schemas';