@lastbrain/ai-ui-react 1.0.51 → 1.0.53
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LBApiKeySelector.d.ts","sourceRoot":"","sources":["../../src/components/LBApiKeySelector.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,UAAU,qBAAqB;IAC7B,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"LBApiKeySelector.d.ts","sourceRoot":"","sources":["../../src/components/LBApiKeySelector.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,UAAU,qBAAqB;IAC7B,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE,qBAAqB,kDAwTvB"}
|
|
@@ -79,9 +79,7 @@ export function LBApiKeySelector({ apiKeys, onSelect, onCancel, isOpen, }) {
|
|
|
79
79
|
background: isSelected
|
|
80
80
|
? "light-dark(#f1f5f9, #334155)"
|
|
81
81
|
: "light-dark(#f8fafc, #0f172a)",
|
|
82
|
-
border: `2px solid ${isSelected
|
|
83
|
-
? "#8b5cf6"
|
|
84
|
-
: "light-dark(#e2e8f0, #334155)"}`,
|
|
82
|
+
border: `2px solid ${isSelected ? "#8b5cf6" : "light-dark(#e2e8f0, #334155)"}`,
|
|
85
83
|
borderRadius: "8px",
|
|
86
84
|
cursor: isActive ? "pointer" : "not-allowed",
|
|
87
85
|
opacity: isActive ? 1 : 0.5,
|
|
@@ -5,6 +5,12 @@ import { useLB } from "../context/LBAuthProvider";
|
|
|
5
5
|
import { LBApiKeySelector } from "./LBApiKeySelector";
|
|
6
6
|
import { Mail, Lock, Sparkles, X, Loader2, AlertCircle } from "lucide-react";
|
|
7
7
|
export function LBSigninModal({ isOpen, onClose }) {
|
|
8
|
+
// React Hooks doivent être appelés avant toute condition ou return
|
|
9
|
+
const [email, setEmail] = useState("");
|
|
10
|
+
const [password, setPassword] = useState("");
|
|
11
|
+
const [loading, setLoading] = useState(false);
|
|
12
|
+
const [error, setError] = useState("");
|
|
13
|
+
const [showKeySelector, setShowKeySelector] = useState(false);
|
|
8
14
|
// Vérifier si LBProvider est disponible
|
|
9
15
|
let login;
|
|
10
16
|
let selectApiKeyWithToken;
|
|
@@ -21,17 +27,12 @@ export function LBSigninModal({ isOpen, onClose }) {
|
|
|
21
27
|
// LBProvider n'est pas disponible, ne pas rendre le modal
|
|
22
28
|
return null;
|
|
23
29
|
}
|
|
24
|
-
const [email, setEmail] = useState("");
|
|
25
|
-
const [password, setPassword] = useState("");
|
|
26
|
-
const [loading, setLoading] = useState(false);
|
|
27
|
-
const [error, setError] = useState("");
|
|
28
|
-
const [showKeySelector, setShowKeySelector] = useState(false);
|
|
29
30
|
// Si le status est "needs_key_selection", afficher le sélecteur
|
|
30
31
|
useEffect(() => {
|
|
31
|
-
if (lbStatus === "needs_key_selection" && apiKeys.length > 0) {
|
|
32
|
+
if (lbStatus === "needs_key_selection" && apiKeys.length > 0 && !showKeySelector) {
|
|
32
33
|
setShowKeySelector(true);
|
|
33
34
|
}
|
|
34
|
-
}, [lbStatus, apiKeys.length]);
|
|
35
|
+
}, [lbStatus, apiKeys.length, showKeySelector]);
|
|
35
36
|
if (!isOpen || !login)
|
|
36
37
|
return null;
|
|
37
38
|
const handleSubmit = async (e) => {
|
|
@@ -76,9 +77,8 @@ export function LBSigninModal({ isOpen, onClose }) {
|
|
|
76
77
|
};
|
|
77
78
|
const handleCancelKeySelection = () => {
|
|
78
79
|
setShowKeySelector(false);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
setError("");
|
|
80
|
+
// Fermer complètement le modal au lieu de rester dans l'état de sélection
|
|
81
|
+
onClose();
|
|
82
82
|
};
|
|
83
83
|
// Si on doit afficher le sélecteur de clés
|
|
84
84
|
if (showKeySelector && apiKeys.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lastbrain/ai-ui-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.53",
|
|
4
4
|
"description": "Headless React components for LastBrain AI UI Kit",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"lucide-react": "^0.257.0",
|
|
51
|
-
"@lastbrain/ai-ui-core": "1.0.
|
|
51
|
+
"@lastbrain/ai-ui-core": "1.0.41"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^19.2.0",
|
|
@@ -136,9 +136,7 @@ export function LBApiKeySelector({
|
|
|
136
136
|
? "light-dark(#f1f5f9, #334155)"
|
|
137
137
|
: "light-dark(#f8fafc, #0f172a)",
|
|
138
138
|
border: `2px solid ${
|
|
139
|
-
isSelected
|
|
140
|
-
? "#8b5cf6"
|
|
141
|
-
: "light-dark(#e2e8f0, #334155)"
|
|
139
|
+
isSelected ? "#8b5cf6" : "light-dark(#e2e8f0, #334155)"
|
|
142
140
|
}`,
|
|
143
141
|
borderRadius: "8px",
|
|
144
142
|
cursor: isActive ? "pointer" : "not-allowed",
|
|
@@ -11,6 +11,13 @@ export interface LBSigninModalProps {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function LBSigninModal({ isOpen, onClose }: LBSigninModalProps) {
|
|
14
|
+
// React Hooks doivent être appelés avant toute condition ou return
|
|
15
|
+
const [email, setEmail] = useState("");
|
|
16
|
+
const [password, setPassword] = useState("");
|
|
17
|
+
const [loading, setLoading] = useState(false);
|
|
18
|
+
const [error, setError] = useState("");
|
|
19
|
+
const [showKeySelector, setShowKeySelector] = useState(false);
|
|
20
|
+
|
|
14
21
|
// Vérifier si LBProvider est disponible
|
|
15
22
|
let login:
|
|
16
23
|
| ((
|
|
@@ -37,18 +44,12 @@ export function LBSigninModal({ isOpen, onClose }: LBSigninModalProps) {
|
|
|
37
44
|
return null;
|
|
38
45
|
}
|
|
39
46
|
|
|
40
|
-
const [email, setEmail] = useState("");
|
|
41
|
-
const [password, setPassword] = useState("");
|
|
42
|
-
const [loading, setLoading] = useState(false);
|
|
43
|
-
const [error, setError] = useState("");
|
|
44
|
-
const [showKeySelector, setShowKeySelector] = useState(false);
|
|
45
|
-
|
|
46
47
|
// Si le status est "needs_key_selection", afficher le sélecteur
|
|
47
48
|
useEffect(() => {
|
|
48
|
-
if (lbStatus === "needs_key_selection" && apiKeys.length > 0) {
|
|
49
|
+
if (lbStatus === "needs_key_selection" && apiKeys.length > 0 && !showKeySelector) {
|
|
49
50
|
setShowKeySelector(true);
|
|
50
51
|
}
|
|
51
|
-
}, [lbStatus, apiKeys.length]);
|
|
52
|
+
}, [lbStatus, apiKeys.length, showKeySelector]);
|
|
52
53
|
|
|
53
54
|
if (!isOpen || !login) return null;
|
|
54
55
|
|
|
@@ -96,9 +97,8 @@ export function LBSigninModal({ isOpen, onClose }: LBSigninModalProps) {
|
|
|
96
97
|
|
|
97
98
|
const handleCancelKeySelection = () => {
|
|
98
99
|
setShowKeySelector(false);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
setError("");
|
|
100
|
+
// Fermer complètement le modal au lieu de rester dans l'état de sélection
|
|
101
|
+
onClose();
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
// Si on doit afficher le sélecteur de clés
|