@djangocfg/layouts 2.1.346 → 2.1.347

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/layouts",
3
- "version": "2.1.346",
3
+ "version": "2.1.347",
4
4
  "description": "Simple, straightforward layout components for Next.js - import and use with props",
5
5
  "keywords": [
6
6
  "layouts",
@@ -84,13 +84,13 @@
84
84
  "check": "tsc --noEmit"
85
85
  },
86
86
  "peerDependencies": {
87
- "@djangocfg/api": "^2.1.346",
88
- "@djangocfg/centrifugo": "^2.1.346",
89
- "@djangocfg/debuger": "^2.1.346",
90
- "@djangocfg/i18n": "^2.1.346",
91
- "@djangocfg/monitor": "^2.1.346",
92
- "@djangocfg/ui-core": "^2.1.346",
93
- "@djangocfg/ui-nextjs": "^2.1.346",
87
+ "@djangocfg/api": "^2.1.347",
88
+ "@djangocfg/centrifugo": "^2.1.347",
89
+ "@djangocfg/debuger": "^2.1.347",
90
+ "@djangocfg/i18n": "^2.1.347",
91
+ "@djangocfg/monitor": "^2.1.347",
92
+ "@djangocfg/ui-core": "^2.1.347",
93
+ "@djangocfg/ui-nextjs": "^2.1.347",
94
94
  "@hookform/resolvers": "^5.2.2",
95
95
  "consola": "^3.4.2",
96
96
  "lucide-react": "^0.545.0",
@@ -120,15 +120,15 @@
120
120
  "uuid": "^11.1.0"
121
121
  },
122
122
  "devDependencies": {
123
- "@djangocfg/api": "^2.1.346",
124
- "@djangocfg/centrifugo": "^2.1.346",
125
- "@djangocfg/debuger": "^2.1.346",
126
- "@djangocfg/i18n": "^2.1.346",
127
- "@djangocfg/monitor": "^2.1.346",
128
- "@djangocfg/typescript-config": "^2.1.346",
129
- "@djangocfg/ui-core": "^2.1.346",
130
- "@djangocfg/ui-nextjs": "^2.1.346",
131
- "@djangocfg/ui-tools": "^2.1.346",
123
+ "@djangocfg/api": "^2.1.347",
124
+ "@djangocfg/centrifugo": "^2.1.347",
125
+ "@djangocfg/debuger": "^2.1.347",
126
+ "@djangocfg/i18n": "^2.1.347",
127
+ "@djangocfg/monitor": "^2.1.347",
128
+ "@djangocfg/typescript-config": "^2.1.347",
129
+ "@djangocfg/ui-core": "^2.1.347",
130
+ "@djangocfg/ui-nextjs": "^2.1.347",
131
+ "@djangocfg/ui-tools": "^2.1.347",
132
132
  "@types/node": "^24.7.2",
133
133
  "@types/react": "^19.1.0",
134
134
  "@types/react-dom": "^19.1.0",
@@ -100,7 +100,7 @@ import { AuthLayout } from '@djangocfg/layouts';
100
100
  | Step | Description |
101
101
  |---|---|
102
102
  | `identifier` | Email or phone input |
103
- | `otp` | 6-digit OTP code entry |
103
+ | `otp` | 4-digit email OTP code entry |
104
104
  | `2fa` | TOTP or backup code verification |
105
105
  | `2fa-setup` | QR code + backup codes setup |
106
106
  | `success` | Full-screen success overlay → redirect |
@@ -13,12 +13,13 @@ export interface AuthOTPInputProps {
13
13
  disabled?: boolean;
14
14
  autoFocus?: boolean;
15
15
  size?: 'sm' | 'default' | 'lg';
16
+ length?: number;
16
17
  }
17
18
 
18
19
  /**
19
20
  * AuthOTPInput - Reusable OTP input with consistent styling
20
21
  *
21
- * Used in: OTPStep, TwoFactorStep, SetupStep
22
+ * Used in: OTPStep (email, 4 digits), TwoFactorStep (TOTP, 6 digits), SetupStep (TOTP, 6 digits)
22
23
  */
23
24
  export const AuthOTPInput: React.FC<AuthOTPInputProps> = ({
24
25
  value,
@@ -27,10 +28,11 @@ export const AuthOTPInput: React.FC<AuthOTPInputProps> = ({
27
28
  disabled = false,
28
29
  autoFocus = true,
29
30
  size,
31
+ length = AUTH.TOTP_LENGTH,
30
32
  }) => (
31
33
  <div className="auth-otp-container auth-otp-wrapper">
32
34
  <OTPInput
33
- length={AUTH.OTP_LENGTH}
35
+ length={length}
34
36
  validationMode="numeric"
35
37
  pasteBehavior="clean"
36
38
  value={value}
@@ -66,7 +66,7 @@ export const OTPStep: React.FC = () => {
66
66
  const handleOTPComplete = useCallback(
67
67
  async (completedValue: string) => {
68
68
  if (submitState !== 'idle' || isLoading || isAutoSubmittingFromUrl.current) return;
69
- if (completedValue.length !== AUTH.OTP_LENGTH) return;
69
+ if (completedValue.length !== AUTH.EMAIL_OTP_LENGTH) return;
70
70
 
71
71
  setSubmitState('submitting');
72
72
  const fakeEvent = { preventDefault: () => {} } as React.FormEvent;
@@ -96,6 +96,8 @@ export const OTPStep: React.FC = () => {
96
96
  onChange={setOtp}
97
97
  onComplete={handleOTPComplete}
98
98
  disabled={isLoading}
99
+ length={AUTH.EMAIL_OTP_LENGTH}
100
+ size="lg"
99
101
  />
100
102
 
101
103
  {config.isDevelopment && (
@@ -104,7 +106,7 @@ export const OTPStep: React.FC = () => {
104
106
 
105
107
  <AuthError message={error} />
106
108
 
107
- <AuthButton loading={isLoading} disabled={otp.length < AUTH.OTP_LENGTH}>
109
+ <AuthButton loading={isLoading} disabled={otp.length < AUTH.EMAIL_OTP_LENGTH}>
108
110
  {content.button}
109
111
  </AuthButton>
110
112
 
@@ -117,7 +117,7 @@ export const SetupQRCode: React.FC<SetupQRCodeProps> = ({
117
117
 
118
118
  <AuthButton
119
119
  loading={isLoading}
120
- disabled={confirmCode.length !== AUTH.OTP_LENGTH}
120
+ disabled={confirmCode.length !== AUTH.TOTP_LENGTH}
121
121
  >
122
122
  {content.button}
123
123
  </AuthButton>
@@ -105,7 +105,7 @@ export const TwoFactorStep: React.FC = () => {
105
105
 
106
106
  <AuthButton
107
107
  loading={is2FALoading}
108
- disabled={!useBackupCode && twoFactorCode.length !== AUTH.OTP_LENGTH}
108
+ disabled={!useBackupCode && twoFactorCode.length !== AUTH.TOTP_LENGTH}
109
109
  >
110
110
  {content.button}
111
111
  </AuthButton>
@@ -1,13 +1,18 @@
1
1
  /**
2
2
  * AuthLayout Constants
3
3
  *
4
- * All magic numbers extracted for clarity and maintainability.
4
+ * Code lengths come from the shared single source of truth in
5
+ * `@djangocfg/api/auth` (AUTH_CONSTANTS). Layout-only values (timings, sizes,
6
+ * routes) live here.
5
7
  */
6
8
 
9
+ import { AUTH_CONSTANTS } from '@djangocfg/api/auth';
10
+
7
11
  export const AUTH = {
8
- // Input lengths
9
- OTP_LENGTH: 6,
10
- BACKUP_CODE_MAX_LENGTH: 12,
12
+ // Input lengths (re-exported from @djangocfg/api/auth)
13
+ EMAIL_OTP_LENGTH: AUTH_CONSTANTS.EMAIL_OTP_LENGTH,
14
+ TOTP_LENGTH: AUTH_CONSTANTS.TOTP_LENGTH,
15
+ BACKUP_CODE_MAX_LENGTH: AUTH_CONSTANTS.BACKUP_CODE_MAX_LENGTH,
11
16
 
12
17
  // Timing (ms)
13
18
  ANIMATION_DURATION: 400,