@lastbrain/ai-ui-react 1.0.37 → 1.0.38
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/dist/components/ErrorToast.js +14 -14
- package/dist/hooks/useAiModels.d.ts.map +1 -1
- package/dist/hooks/useAiModels.js +1 -2
- package/dist/hooks/usePrompts.d.ts.map +1 -1
- package/dist/hooks/usePrompts.js +12 -3
- package/package.json +2 -2
- package/src/components/ErrorToast.tsx +16 -16
- package/src/hooks/useAiModels.ts +1 -2
- package/src/hooks/usePrompts.ts +13 -3
|
@@ -7,6 +7,19 @@ export function ErrorToast({ error, position = "bottom-right", onComplete, }) {
|
|
|
7
7
|
const [isClosing, setIsClosing] = useState(false);
|
|
8
8
|
const fadeTimeoutRef = useRef(null);
|
|
9
9
|
const autoCloseTimeoutRef = useRef(null);
|
|
10
|
+
const handleClose = () => {
|
|
11
|
+
if (isClosing)
|
|
12
|
+
return;
|
|
13
|
+
// Clear auto-close timeout if user closes manually
|
|
14
|
+
if (autoCloseTimeoutRef.current) {
|
|
15
|
+
window.clearTimeout(autoCloseTimeoutRef.current);
|
|
16
|
+
}
|
|
17
|
+
setIsClosing(true);
|
|
18
|
+
fadeTimeoutRef.current = window.setTimeout(() => {
|
|
19
|
+
setIsVisible(false);
|
|
20
|
+
onComplete?.();
|
|
21
|
+
}, 200);
|
|
22
|
+
};
|
|
10
23
|
useEffect(() => {
|
|
11
24
|
if (error) {
|
|
12
25
|
// Show toast immediately
|
|
@@ -27,20 +40,7 @@ export function ErrorToast({ error, position = "bottom-right", onComplete, }) {
|
|
|
27
40
|
window.clearTimeout(autoCloseTimeoutRef.current);
|
|
28
41
|
}
|
|
29
42
|
};
|
|
30
|
-
}, [error]);
|
|
31
|
-
const handleClose = () => {
|
|
32
|
-
if (isClosing)
|
|
33
|
-
return;
|
|
34
|
-
// Clear auto-close timeout if user closes manually
|
|
35
|
-
if (autoCloseTimeoutRef.current) {
|
|
36
|
-
window.clearTimeout(autoCloseTimeoutRef.current);
|
|
37
|
-
}
|
|
38
|
-
setIsClosing(true);
|
|
39
|
-
fadeTimeoutRef.current = window.setTimeout(() => {
|
|
40
|
-
setIsVisible(false);
|
|
41
|
-
onComplete?.();
|
|
42
|
-
}, 200);
|
|
43
|
-
};
|
|
43
|
+
}, [error, handleClose]);
|
|
44
44
|
if (!error)
|
|
45
45
|
return null;
|
|
46
46
|
const getPositionStyles = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAiModels.d.ts","sourceRoot":"","sources":["../../src/hooks/useAiModels.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtD,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,kBAAkB,CAAC;CAC1E;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,iBAAiB,
|
|
1
|
+
{"version":3,"file":"useAiModels.d.ts","sourceRoot":"","sources":["../../src/hooks/useAiModels.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtD,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,kBAAkB,CAAC;CAC1E;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,iBAAiB,CA8F3E"}
|
|
@@ -52,8 +52,7 @@ export function useAiModels(options) {
|
|
|
52
52
|
const filtered = context.getModelsByType(options.modelType);
|
|
53
53
|
console.log(`[useAiModels] Returning ${options.modelType} models:`, filtered.length);
|
|
54
54
|
return filtered;
|
|
55
|
-
|
|
56
|
-
}, [useContextData, context, options?.modelType]);
|
|
55
|
+
}, [useContextData, context, options]);
|
|
57
56
|
const refetch = useCallback(() => {
|
|
58
57
|
if (useContextData) {
|
|
59
58
|
context.refetchProviders();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrompts.d.ts","sourceRoot":"","sources":["../../src/hooks/usePrompts.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAa,SAAQ,MAAM;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,M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AC,CAAC;CACpB;AAED,wBAAgB,UAAU,IAAI,gBAAgB,CAgS7C"}
|
package/dist/hooks/usePrompts.js
CHANGED
|
@@ -23,7 +23,10 @@ export function usePrompts() {
|
|
|
23
23
|
// Check cache first (60 seconds TTL)
|
|
24
24
|
const cached = getCached(cacheKey, 60000);
|
|
25
25
|
if (cached) {
|
|
26
|
-
console.log("[usePrompts] Using cached data",
|
|
26
|
+
console.log("[usePrompts] Using cached data:", {
|
|
27
|
+
count: cached.length,
|
|
28
|
+
prompts: cached,
|
|
29
|
+
});
|
|
27
30
|
setPrompts(cached);
|
|
28
31
|
setLoading(false);
|
|
29
32
|
return;
|
|
@@ -76,6 +79,12 @@ export function usePrompts() {
|
|
|
76
79
|
credentials: isExternalProxy ? "include" : "same-origin",
|
|
77
80
|
});
|
|
78
81
|
const data = await response.json();
|
|
82
|
+
console.log("[usePrompts] Server response:", {
|
|
83
|
+
ok: response.ok,
|
|
84
|
+
status: response.status,
|
|
85
|
+
promptsCount: data.prompts?.length || 0,
|
|
86
|
+
data,
|
|
87
|
+
});
|
|
79
88
|
if (response.ok) {
|
|
80
89
|
const promptsData = data.prompts || [];
|
|
81
90
|
setPrompts(promptsData);
|
|
@@ -92,7 +101,7 @@ export function usePrompts() {
|
|
|
92
101
|
finally {
|
|
93
102
|
setLoading(false);
|
|
94
103
|
}
|
|
95
|
-
}, [baseUrl]);
|
|
104
|
+
}, [baseUrl, apiKeyId]);
|
|
96
105
|
const createPrompt = useCallback(async (data) => {
|
|
97
106
|
try {
|
|
98
107
|
setError(null);
|
|
@@ -223,7 +232,7 @@ export function usePrompts() {
|
|
|
223
232
|
credentials: isExternalProxy ? "include" : "same-origin",
|
|
224
233
|
});
|
|
225
234
|
}
|
|
226
|
-
catch
|
|
235
|
+
catch {
|
|
227
236
|
// Silent fail for stats
|
|
228
237
|
}
|
|
229
238
|
}, [baseUrl, apiKeyId]);
|
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.38",
|
|
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.28"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^19.2.0",
|
|
@@ -24,6 +24,21 @@ export function ErrorToast({
|
|
|
24
24
|
const fadeTimeoutRef = useRef<number | null>(null);
|
|
25
25
|
const autoCloseTimeoutRef = useRef<number | null>(null);
|
|
26
26
|
|
|
27
|
+
const handleClose = () => {
|
|
28
|
+
if (isClosing) return;
|
|
29
|
+
|
|
30
|
+
// Clear auto-close timeout if user closes manually
|
|
31
|
+
if (autoCloseTimeoutRef.current) {
|
|
32
|
+
window.clearTimeout(autoCloseTimeoutRef.current);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setIsClosing(true);
|
|
36
|
+
fadeTimeoutRef.current = window.setTimeout(() => {
|
|
37
|
+
setIsVisible(false);
|
|
38
|
+
onComplete?.();
|
|
39
|
+
}, 200);
|
|
40
|
+
};
|
|
41
|
+
|
|
27
42
|
useEffect(() => {
|
|
28
43
|
if (error) {
|
|
29
44
|
// Show toast immediately
|
|
@@ -46,22 +61,7 @@ export function ErrorToast({
|
|
|
46
61
|
window.clearTimeout(autoCloseTimeoutRef.current);
|
|
47
62
|
}
|
|
48
63
|
};
|
|
49
|
-
}, [error]);
|
|
50
|
-
|
|
51
|
-
const handleClose = () => {
|
|
52
|
-
if (isClosing) return;
|
|
53
|
-
|
|
54
|
-
// Clear auto-close timeout if user closes manually
|
|
55
|
-
if (autoCloseTimeoutRef.current) {
|
|
56
|
-
window.clearTimeout(autoCloseTimeoutRef.current);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
setIsClosing(true);
|
|
60
|
-
fadeTimeoutRef.current = window.setTimeout(() => {
|
|
61
|
-
setIsVisible(false);
|
|
62
|
-
onComplete?.();
|
|
63
|
-
}, 200);
|
|
64
|
-
};
|
|
64
|
+
}, [error, handleClose]);
|
|
65
65
|
|
|
66
66
|
if (!error) return null;
|
|
67
67
|
|
package/src/hooks/useAiModels.ts
CHANGED
|
@@ -87,8 +87,7 @@ export function useAiModels(options?: UseAiModelsOptions): UseAiModelsResult {
|
|
|
87
87
|
filtered.length
|
|
88
88
|
);
|
|
89
89
|
return filtered;
|
|
90
|
-
|
|
91
|
-
}, [useContextData, context, options?.modelType]);
|
|
90
|
+
}, [useContextData, context, options]);
|
|
92
91
|
|
|
93
92
|
const refetch = useCallback(() => {
|
|
94
93
|
if (useContextData) {
|
package/src/hooks/usePrompts.ts
CHANGED
|
@@ -79,7 +79,10 @@ export function usePrompts(): UsePromptsReturn {
|
|
|
79
79
|
// Check cache first (60 seconds TTL)
|
|
80
80
|
const cached = getCached<Prompt[] | PublicPrompt[]>(cacheKey, 60000);
|
|
81
81
|
if (cached) {
|
|
82
|
-
console.log("[usePrompts] Using cached data",
|
|
82
|
+
console.log("[usePrompts] Using cached data:", {
|
|
83
|
+
count: cached.length,
|
|
84
|
+
prompts: cached,
|
|
85
|
+
});
|
|
83
86
|
setPrompts(cached);
|
|
84
87
|
setLoading(false);
|
|
85
88
|
return;
|
|
@@ -141,6 +144,13 @@ export function usePrompts(): UsePromptsReturn {
|
|
|
141
144
|
|
|
142
145
|
const data = await response.json();
|
|
143
146
|
|
|
147
|
+
console.log("[usePrompts] Server response:", {
|
|
148
|
+
ok: response.ok,
|
|
149
|
+
status: response.status,
|
|
150
|
+
promptsCount: data.prompts?.length || 0,
|
|
151
|
+
data,
|
|
152
|
+
});
|
|
153
|
+
|
|
144
154
|
if (response.ok) {
|
|
145
155
|
const promptsData = data.prompts || [];
|
|
146
156
|
setPrompts(promptsData);
|
|
@@ -155,7 +165,7 @@ export function usePrompts(): UsePromptsReturn {
|
|
|
155
165
|
setLoading(false);
|
|
156
166
|
}
|
|
157
167
|
},
|
|
158
|
-
[baseUrl]
|
|
168
|
+
[baseUrl, apiKeyId]
|
|
159
169
|
);
|
|
160
170
|
|
|
161
171
|
const createPrompt = useCallback(
|
|
@@ -314,7 +324,7 @@ export function usePrompts(): UsePromptsReturn {
|
|
|
314
324
|
body: JSON.stringify({ prompt_id: promptId, stat_type: statType }),
|
|
315
325
|
credentials: isExternalProxy ? "include" : "same-origin",
|
|
316
326
|
});
|
|
317
|
-
} catch
|
|
327
|
+
} catch {
|
|
318
328
|
// Silent fail for stats
|
|
319
329
|
}
|
|
320
330
|
},
|