@djangocfg/layouts 2.1.52 → 2.1.54

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.52",
3
+ "version": "2.1.54",
4
4
  "description": "Simple, straightforward layout components for Next.js - import and use with props",
5
5
  "keywords": [
6
6
  "layouts",
@@ -92,9 +92,9 @@
92
92
  "check": "tsc --noEmit"
93
93
  },
94
94
  "peerDependencies": {
95
- "@djangocfg/api": "^2.1.52",
96
- "@djangocfg/centrifugo": "^2.1.52",
97
- "@djangocfg/ui-nextjs": "^2.1.52",
95
+ "@djangocfg/api": "^2.1.54",
96
+ "@djangocfg/centrifugo": "^2.1.54",
97
+ "@djangocfg/ui-nextjs": "^2.1.54",
98
98
  "@hookform/resolvers": "^5.2.0",
99
99
  "consola": "^3.4.2",
100
100
  "lucide-react": "^0.545.0",
@@ -116,7 +116,7 @@
116
116
  "uuid": "^11.1.0"
117
117
  },
118
118
  "devDependencies": {
119
- "@djangocfg/typescript-config": "^2.1.52",
119
+ "@djangocfg/typescript-config": "^2.1.54",
120
120
  "@types/node": "^24.7.2",
121
121
  "@types/react": "^19.1.0",
122
122
  "@types/react-dom": "^19.1.0",
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { ArrowLeft, Mail, MessageCircle, RotateCw, ShieldCheck } from 'lucide-react';
4
- import React from 'react';
4
+ import React, { useCallback, useRef } from 'react';
5
5
 
6
6
  import {
7
7
  Button, Card, CardContent, CardDescription, CardHeader, CardTitle, OTPInput
@@ -25,6 +25,30 @@ export const OTPForm: React.FC = () => {
25
25
  handleBackToIdentifier,
26
26
  } = useAuthContext();
27
27
 
28
+ // Ref to track if auto-submit is in progress to prevent duplicate submissions
29
+ const isAutoSubmittingRef = useRef(false);
30
+
31
+ // Handle auto-submit when OTP is complete (after paste or last digit entry)
32
+ const handleOTPComplete = useCallback((completedValue: string) => {
33
+ // Prevent duplicate submissions
34
+ if (isAutoSubmittingRef.current || isLoading) return;
35
+
36
+ if (completedValue.length === 6) {
37
+ isAutoSubmittingRef.current = true;
38
+
39
+ // Create a fake form event for handleOTPSubmit
40
+ const fakeEvent = {
41
+ preventDefault: () => {},
42
+ } as React.FormEvent;
43
+
44
+ // Small delay to ensure state is updated
45
+ setTimeout(() => {
46
+ handleOTPSubmit(fakeEvent);
47
+ isAutoSubmittingRef.current = false;
48
+ }, 100);
49
+ }
50
+ }, [handleOTPSubmit, isLoading]);
51
+
28
52
  const getChannelIcon = () => {
29
53
  return channel === 'phone' ? (
30
54
  <div className="flex items-center justify-center">
@@ -71,6 +95,7 @@ export const OTPForm: React.FC = () => {
71
95
  pasteBehavior="clean"
72
96
  value={otp}
73
97
  onChange={setOtp}
98
+ onComplete={handleOTPComplete}
74
99
  disabled={isLoading}
75
100
  autoFocus={true}
76
101
  autoSubmit={true}