doct-ui-auth-kit 1.0.5 → 1.0.6

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.
@@ -11,6 +11,16 @@ export type LoginEntrySubmitData = {
11
11
  phone?: string;
12
12
  email?: string;
13
13
  };
14
+ /**
15
+ * Params passed to onSuccess after submitApi resolves.
16
+ * Lets the consumer redirect to OTP with mode and recipient (for recipientDisplay) without storing them in refs.
17
+ */
18
+ export interface LoginEntrySuccessParams {
19
+ /** Current login entry mode (phone or email). */
20
+ mode: LoginEntryMode;
21
+ /** Submitted phone or email string; use for OTP page recipientDisplay or verify API. */
22
+ recipient: string;
23
+ }
14
24
  export interface UseLoginEntryFormOptions {
15
25
  mode: LoginEntryMode;
16
26
  /**
@@ -19,12 +29,12 @@ export interface UseLoginEntryFormOptions {
19
29
  */
20
30
  onSubmit?: ((data: LoginEntrySubmitData) => void) | undefined;
21
31
  /**
22
- * When provided, hook runs business logic: validate → call submitApi(data) → onSuccess().
23
- * Use from consumer (e.g. Next.js): submitApi = sendOtp, onSuccess = () => router.push('/otp').
32
+ * When provided, hook runs business logic: validate → call submitApi(data) → onSuccess(params).
33
+ * Use from consumer (e.g. Next.js): submitApi = sendOtp, onSuccess = (params) => router.push(`/otp?mode=${params.mode}&recipient=${encodeURIComponent(params.recipient)}`).
24
34
  */
25
35
  submitApi?: (data: LoginEntrySubmitData) => Promise<void>;
26
- /** Called after submitApi resolves successfully (e.g. redirect to OTP page). */
27
- onSuccess?: () => void;
36
+ /** Called after submitApi resolves successfully; receives mode and recipient for OTP redirect/display. */
37
+ onSuccess?: (params: LoginEntrySuccessParams) => void;
28
38
  /** Called when submitApi rejects or throws. */
29
39
  onError?: (error: unknown) => void;
30
40
  }
@@ -19,6 +19,8 @@ export interface UseOtpVerificationOptions {
19
19
  export interface UseOtpVerificationReturn {
20
20
  methods: UseFormReturn<OtpFormValues>;
21
21
  handleSubmit: (data: OtpFormValues) => void;
22
+ /** True when current form values pass validation (for disabling Submit until valid – edge case 6). */
23
+ isFormValid: (data: OtpFormValues) => boolean;
22
24
  handleResend: () => void;
23
25
  resendSecondsLeft: number;
24
26
  canResend: boolean;
@@ -34,8 +34,11 @@ export interface LoginEntryProps {
34
34
  phone?: string;
35
35
  email?: string;
36
36
  }) => Promise<void>;
37
- /** Called after submitApi succeeds (e.g. router.push('/otp')). */
38
- onSuccess?: () => void;
37
+ /** Called after submitApi succeeds; receives { mode, recipient } for OTP redirect/recipientDisplay. */
38
+ onSuccess?: (params: {
39
+ mode: LoginEntryMode;
40
+ recipient: string;
41
+ }) => void;
39
42
  /** Called when submitApi fails. */
40
43
  onError?: (error: unknown) => void;
41
44
  }
@@ -6,15 +6,16 @@ import { z } from 'zod';
6
6
  /** Capitalize first letter of each word (PRODUCT_PROTOCOLS #25 – Naming conventions). */
7
7
  export declare function capitalizeWords(value: string): string;
8
8
  /**
9
- * Full name: min 3 chars, trim, capitalize each word (Protocol #1, #25; Edge case 9).
9
+ * Full name: required, min 3 chars, trim, capitalize each word (Protocol #1, #25; Edge case 9).
10
10
  */
11
11
  export declare const fullNameSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
12
12
  /**
13
- * Phone: digits only, length between 7 and 15.
13
+ * Phone: required; national part (after "-") digits only, length between 7 and 15.
14
+ * Matches Storybook/react-hook-form validate: value format "countryCode-nationalNumber" (e.g. "91-9876543210").
14
15
  */
15
16
  export declare const phoneSchema: z.ZodString;
16
17
  /**
17
- * Email: trim and lowercase before save (Edge case 10).
18
+ * Email: required, valid format, trim and lowercase before save (Edge case 10).
18
19
  */
19
20
  export declare const emailSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
20
21
  export declare const signupPhoneFormSchema: z.ZodObject<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doct-ui-auth-kit",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Composable React auth SDK – layouts, login/signup/OTP pages, SSO provider, and auth flow hooks for Docthub",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -48,7 +48,7 @@
48
48
  }
49
49
  },
50
50
  "peerDependencies": {
51
- "docthub-core-components": "^2.54.0",
51
+ "docthub-core-components": "^2.57.0",
52
52
  "react": "^19.0.0",
53
53
  "react-dom": "^19.0.0",
54
54
  "react-hook-form": "^7.50.0",
@@ -57,7 +57,7 @@
57
57
  "dependencies": {
58
58
  "clsx": "^2.1.1",
59
59
  "dayjs": "^1.11.19",
60
- "docthub-core-components": "^2.54.0",
60
+ "docthub-core-components": "^2.57.0",
61
61
  "react": "^19.0.0",
62
62
  "react-dom": "^19.0.0",
63
63
  "react-hook-form": "^7.50.0",