doct-ui-auth-kit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +266 -0
  2. package/dist/adapters/http-auth-adapter.d.ts +11 -0
  3. package/dist/adapters/index.d.ts +1 -0
  4. package/dist/auth-methods/apple.d.ts +19 -0
  5. package/dist/auth-methods/google.d.ts +65 -0
  6. package/dist/auth-methods/index.d.ts +2 -0
  7. package/dist/components/auth/repeat-login.d.ts +24 -0
  8. package/dist/components/form/rhf-doct-phone-input.d.ts +2 -0
  9. package/dist/components/form/rhf-input-field.d.ts +2 -0
  10. package/dist/components/form/rhf-otp-input-field.d.ts +2 -0
  11. package/dist/components/form/rhf-password-field.d.ts +2 -0
  12. package/dist/components/layout/auth-layout.d.ts +89 -0
  13. package/dist/components/layout/image-slider.d.ts +45 -0
  14. package/dist/components/layout/index.d.ts +6 -0
  15. package/dist/components/layout/main-layout.d.ts +74 -0
  16. package/dist/constants/demo-slider.d.ts +16 -0
  17. package/dist/constants/index.d.ts +1 -0
  18. package/dist/core/auth-api-adapter.d.ts +38 -0
  19. package/dist/core/auth-context.d.ts +67 -0
  20. package/dist/core/auth-flow.d.ts +5 -0
  21. package/dist/core/auth-provider.d.ts +39 -0
  22. package/dist/core/auth-types.d.ts +68 -0
  23. package/dist/core/device-detection.d.ts +23 -0
  24. package/dist/core/index.d.ts +11 -0
  25. package/dist/core/sso-session.d.ts +35 -0
  26. package/dist/core/use-auth-flow.d.ts +79 -0
  27. package/dist/docthub.svg +5 -0
  28. package/dist/hooks/index.d.ts +3 -0
  29. package/dist/hooks/use-login-entry-form.d.ts +32 -0
  30. package/dist/hooks/use-otp-verification.d.ts +29 -0
  31. package/dist/hooks/use-signup-form.d.ts +37 -0
  32. package/dist/index.d.ts +26 -0
  33. package/dist/index.js +7405 -0
  34. package/dist/logo.png +0 -0
  35. package/dist/pages/conflict.d.ts +12 -0
  36. package/dist/pages/foreign-email-collect.d.ts +16 -0
  37. package/dist/pages/index.d.ts +7 -0
  38. package/dist/pages/login-entry.d.ts +23 -0
  39. package/dist/pages/main-login.d.ts +26 -0
  40. package/dist/pages/otp-verification.d.ts +21 -0
  41. package/dist/pages/repeat-login.d.ts +20 -0
  42. package/dist/pages/signup.d.ts +17 -0
  43. package/dist/pages.js +10 -0
  44. package/dist/signup-Cnybfnhd.js +720 -0
  45. package/dist/slider/slide-1.png +0 -0
  46. package/dist/slider/slide-2.png +0 -0
  47. package/dist/slider/slide-3.png +0 -0
  48. package/dist/slider/slide-4.png +0 -0
  49. package/dist/slider/slide-5.png +0 -0
  50. package/dist/types/auth-layout-types.d.ts +94 -0
  51. package/dist/types/common.d.ts +25 -0
  52. package/dist/types/forms.d.ts +124 -0
  53. package/dist/types/index.d.ts +6 -0
  54. package/dist/types/user.d.ts +31 -0
  55. package/dist/vite.svg +1 -0
  56. package/package.json +104 -0
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,94 @@
1
+ import type { 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
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Common utility types and interfaces used across the application
3
+ */
4
+ export type Nullable<T> = T | null;
5
+ export type Optional<T> = T | undefined;
6
+ export type Maybe<T> = T | null | undefined;
7
+ export type ID = string | number;
8
+ export interface BaseEntity {
9
+ id: ID;
10
+ createdAt?: string;
11
+ updatedAt?: string;
12
+ }
13
+ export type Status = 'idle' | 'loading' | 'success' | 'error';
14
+ export interface ApiResponse<T> {
15
+ data: T;
16
+ message?: string;
17
+ success: boolean;
18
+ }
19
+ export interface PaginatedResponse<T> {
20
+ data: T[];
21
+ total: number;
22
+ page: number;
23
+ limit: number;
24
+ totalPages: number;
25
+ }
@@ -0,0 +1,124 @@
1
+ import type { KeyboardEvent } from 'react';
2
+ import type { Control, FieldValues } from 'react-hook-form';
3
+ export interface BaseFormFieldProps {
4
+ name: string;
5
+ label?: string;
6
+ placeholder?: string;
7
+ required?: boolean;
8
+ disabled?: boolean;
9
+ className?: string;
10
+ error?: string;
11
+ helperText?: string;
12
+ }
13
+ export interface RHFInputFieldProps extends BaseFormFieldProps {
14
+ type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'search';
15
+ autoComplete?: string;
16
+ maxLength?: number;
17
+ minLength?: number;
18
+ pattern?: string;
19
+ control?: Control<FieldValues>;
20
+ onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
21
+ numericOnly?: boolean;
22
+ }
23
+ export interface RHFPasswordFieldProps extends BaseFormFieldProps {
24
+ showPassword?: boolean;
25
+ togglePasswordVisibility?: () => void;
26
+ control?: Control<FieldValues>;
27
+ }
28
+ export interface RHFTextareaFieldProps extends BaseFormFieldProps {
29
+ rows?: number;
30
+ maxLength?: number;
31
+ minLength?: number;
32
+ resize?: 'none' | 'vertical' | 'horizontal' | 'both';
33
+ control?: Control<FieldValues>;
34
+ }
35
+ export interface RHFPhoneInputFieldProps extends BaseFormFieldProps {
36
+ countryCode?: string;
37
+ preferredCountries?: string[];
38
+ enableSearch?: boolean;
39
+ searchPlaceholder?: string;
40
+ autoFormat?: boolean;
41
+ control?: Control<FieldValues>;
42
+ }
43
+ /** Props for RHF wrapper around DoctPhoneInput (docthub-core-components). */
44
+ export interface RHFDoctPhoneInputFieldProps extends BaseFormFieldProps {
45
+ defaultCountry?: string;
46
+ variant?: 'default' | 'flag';
47
+ control?: Control<FieldValues>;
48
+ }
49
+ export interface RHFOtpInputFieldProps extends BaseFormFieldProps {
50
+ length?: number;
51
+ type?: 'text' | 'number' | 'password';
52
+ autoFocus?: boolean;
53
+ autoSubmit?: boolean;
54
+ onComplete?: (otp: string) => void;
55
+ inputClassName?: string;
56
+ control?: Control<FieldValues>;
57
+ }
58
+ export interface FormLayoutProps {
59
+ children: React.ReactNode;
60
+ className?: string;
61
+ onSubmit?: (data: Record<string, unknown>) => void;
62
+ onReset?: () => void;
63
+ }
64
+ export interface FormHeaderProps {
65
+ title: string;
66
+ subtitle?: string;
67
+ onBack?: () => void;
68
+ className?: string;
69
+ }
70
+ export interface FormFooterProps {
71
+ children: React.ReactNode;
72
+ className?: string;
73
+ }
74
+ export interface FormCardProps {
75
+ children: React.ReactNode;
76
+ className?: string;
77
+ title?: string;
78
+ subtitle?: string;
79
+ headerActions?: React.ReactNode;
80
+ footerActions?: React.ReactNode;
81
+ }
82
+ export interface ValidationRule {
83
+ required?: boolean;
84
+ minLength?: number;
85
+ maxLength?: number;
86
+ pattern?: RegExp;
87
+ min?: number;
88
+ max?: number;
89
+ email?: boolean;
90
+ url?: boolean;
91
+ custom?: (value: unknown) => boolean | string;
92
+ }
93
+ export interface FormValidationSchema {
94
+ [fieldName: string]: ValidationRule;
95
+ }
96
+ export interface FormState {
97
+ isValid: boolean;
98
+ isDirty: boolean;
99
+ isSubmitting: boolean;
100
+ errors: Record<string, string>;
101
+ touched: Record<string, boolean>;
102
+ values: Record<string, unknown>;
103
+ }
104
+ export interface FormSubmissionOptions {
105
+ validateOnSubmit?: boolean;
106
+ resetOnSuccess?: boolean;
107
+ showSuccessMessage?: boolean;
108
+ successMessage?: string;
109
+ onSuccess?: (data: Record<string, unknown>) => void;
110
+ onError?: (error: unknown) => void;
111
+ }
112
+ export interface UseFormReturn<T = Record<string, unknown>> {
113
+ register: (name: keyof T) => object;
114
+ handleSubmit: (onSubmit: (data: T) => void) => (e: React.FormEvent) => void;
115
+ watch: (name?: keyof T) => unknown;
116
+ setValue: (name: keyof T, value: T[keyof T]) => void;
117
+ getValues: () => T;
118
+ reset: (values?: T) => void;
119
+ formState: FormState;
120
+ errors: Record<keyof T, string>;
121
+ isValid: boolean;
122
+ isDirty: boolean;
123
+ isSubmitting: boolean;
124
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Central export file for all types and interfaces
3
+ * Import types from here: import type { User, ApiResponse } from '@/types';
4
+ */
5
+ export * from './common';
6
+ export * from './user';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * User-related types and interfaces
3
+ */
4
+ import type { BaseEntity } from './common';
5
+ export interface User extends BaseEntity {
6
+ name: string;
7
+ email: string;
8
+ avatar?: string;
9
+ role?: UserRole;
10
+ }
11
+ export type UserRole = 'admin' | 'user' | 'guest';
12
+ export interface UserProfile extends User {
13
+ bio?: string;
14
+ phone?: string;
15
+ address?: Address;
16
+ }
17
+ export interface Address {
18
+ street?: string;
19
+ city?: string;
20
+ state?: string;
21
+ zipCode?: string;
22
+ country?: string;
23
+ }
24
+ export interface LoginCredentials {
25
+ email: string;
26
+ password: string;
27
+ }
28
+ export interface RegisterData extends LoginCredentials {
29
+ name: string;
30
+ confirmPassword: string;
31
+ }
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json ADDED
@@ -0,0 +1,104 @@
1
+ {
2
+ "name": "doct-ui-auth-kit",
3
+ "version": "1.0.0",
4
+ "description": "Composable React auth SDK – layouts, login/signup/OTP pages, SSO provider, and auth flow hooks for Docthub",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": ["dist", "README.md"],
9
+ "keywords": [
10
+ "react",
11
+ "auth",
12
+ "sdk",
13
+ "docthub",
14
+ "login",
15
+ "signup",
16
+ "sso",
17
+ "otp"
18
+ ],
19
+ "license": "UNLICENSED",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/docthub/doct-ui-auth-kit"
23
+ },
24
+ "scripts": {
25
+ "dev": "vite",
26
+ "build": "tsc -b && vite build && tsc -p tsconfig.build.json",
27
+ "prepublishOnly": "npm run build",
28
+ "lint": "biome lint .",
29
+ "preview": "vite preview",
30
+ "format": "biome format --write .",
31
+ "lint:biome": "biome lint .",
32
+ "check": "biome check .",
33
+ "check:fix": "biome check --write .",
34
+ "type-check": "tsc --noEmit",
35
+ "prepare": "husky",
36
+ "storybook": "storybook dev -p 6006",
37
+ "build-storybook": "storybook build"
38
+ },
39
+ "exports": {
40
+ ".": {
41
+ "types": "./dist/index.d.ts",
42
+ "import": "./dist/index.js"
43
+ },
44
+ "./style.css": "./dist/style.css",
45
+ "./pages": {
46
+ "types": "./dist/pages/index.d.ts",
47
+ "import": "./dist/pages.js"
48
+ }
49
+ },
50
+ "peerDependencies": {
51
+ "react": "^19.0.0",
52
+ "react-dom": "^19.0.0",
53
+ "docthub-core-components": "^2.54.0",
54
+ "react-hook-form": "^7.50.0",
55
+ "zod": "^4.0.0"
56
+ },
57
+ "dependencies": {
58
+ "clsx": "^2.1.1",
59
+ "dayjs": "^1.11.19",
60
+ "docthub-core-components": "^2.54.0",
61
+ "react": "^19.2.0",
62
+ "react-dom": "^19.2.0",
63
+ "react-hook-form": "^7.71.1",
64
+ "react-icons": "^5.5.0",
65
+ "react-phone-number-input": "^3.4.14",
66
+ "zod": "^4.3.6"
67
+ },
68
+ "devDependencies": {
69
+ "@biomejs/biome": "^2.3.14",
70
+ "@chromatic-com/storybook": "^5.0.0",
71
+ "@eslint/js": "^9.39.1",
72
+ "@storybook/addon-a11y": "^10.2.6",
73
+ "@storybook/addon-docs": "^10.2.6",
74
+ "@storybook/addon-onboarding": "^10.2.6",
75
+ "@storybook/addon-vitest": "^10.2.6",
76
+ "@storybook/react-vite": "^10.2.6",
77
+ "@types/node": "^24.10.1",
78
+ "@types/react": "^19.2.5",
79
+ "@types/react-dom": "^19.2.3",
80
+ "@vitejs/plugin-react": "^5.1.1",
81
+ "@vitest/browser-playwright": "^4.0.18",
82
+ "@vitest/coverage-v8": "^4.0.18",
83
+ "autoprefixer": "^10.4.24",
84
+ "babel-plugin-react-compiler": "^1.0.0",
85
+ "eslint": "^9.39.1",
86
+ "eslint-plugin-react-hooks": "^7.0.1",
87
+ "eslint-plugin-react-refresh": "^0.4.24",
88
+ "glob": "^13.0.1",
89
+ "globals": "^16.5.0",
90
+ "husky": "^9.1.7",
91
+ "lint-staged": "^16.2.7",
92
+ "playwright": "^1.58.1",
93
+ "postcss": "^8.5.6",
94
+ "storybook": "^10.2.6",
95
+ "tailwind-merge": "^3.0.1",
96
+ "tailwindcss": "^3.4.16",
97
+ "tailwindcss-animate": "^1.0.7",
98
+ "typescript": "~5.6.2",
99
+ "typescript-eslint": "^8.46.4",
100
+ "vite": "^7.2.4",
101
+ "vitest": "^4.0.18",
102
+ "vite-plugin-dts": "^4.5.0"
103
+ }
104
+ }