@lastbrain/ai-ui-react 1.0.67 → 1.0.69
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/AiChipLabel.d.ts +8 -3
- package/dist/components/AiChipLabel.d.ts.map +1 -1
- package/dist/components/AiChipLabel.js +21 -70
- package/dist/components/AiContextButton.d.ts +5 -1
- package/dist/components/AiContextButton.d.ts.map +1 -1
- package/dist/components/AiContextButton.js +67 -291
- package/dist/components/AiImageButton.d.ts +5 -1
- package/dist/components/AiImageButton.d.ts.map +1 -1
- package/dist/components/AiImageButton.js +6 -142
- package/dist/components/AiInput.d.ts +5 -3
- package/dist/components/AiInput.d.ts.map +1 -1
- package/dist/components/AiInput.js +13 -25
- package/dist/components/AiPromptPanel.d.ts.map +1 -1
- package/dist/components/AiPromptPanel.js +58 -212
- package/dist/components/AiSelect.d.ts +5 -3
- package/dist/components/AiSelect.d.ts.map +1 -1
- package/dist/components/AiSelect.js +21 -30
- package/dist/components/AiStatusButton.d.ts +4 -1
- package/dist/components/AiStatusButton.d.ts.map +1 -1
- package/dist/components/AiStatusButton.js +198 -626
- package/dist/components/AiTextarea.d.ts +4 -2
- package/dist/components/AiTextarea.d.ts.map +1 -1
- package/dist/components/AiTextarea.js +14 -26
- package/dist/components/LBApiKeySelector.d.ts.map +1 -1
- package/dist/components/LBApiKeySelector.js +5 -166
- package/dist/components/LBConnectButton.d.ts +4 -7
- package/dist/components/LBConnectButton.d.ts.map +1 -1
- package/dist/components/LBConnectButton.js +17 -86
- package/dist/components/LBSigninModal.d.ts +1 -1
- package/dist/components/LBSigninModal.d.ts.map +1 -1
- package/dist/components/LBSigninModal.js +42 -320
- package/dist/examples/AiUiPremiumShowcase.d.ts +2 -0
- package/dist/examples/AiUiPremiumShowcase.d.ts.map +1 -0
- package/dist/examples/AiUiPremiumShowcase.js +15 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/styles/inline.d.ts +1 -0
- package/dist/styles/inline.d.ts.map +1 -1
- package/dist/styles/inline.js +25 -129
- package/dist/styles.css +1268 -369
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/AiChipLabel.tsx +64 -101
- package/src/components/AiContextButton.tsx +138 -430
- package/src/components/AiImageButton.tsx +29 -190
- package/src/components/AiInput.tsx +49 -74
- package/src/components/AiPromptPanel.tsx +71 -254
- package/src/components/AiSelect.tsx +61 -69
- package/src/components/AiStatusButton.tsx +477 -1219
- package/src/components/AiTextarea.tsx +49 -64
- package/src/components/LBApiKeySelector.tsx +86 -274
- package/src/components/LBConnectButton.tsx +46 -334
- package/src/components/LBSigninModal.tsx +140 -481
- package/src/examples/AiUiPremiumShowcase.tsx +91 -0
- package/src/index.ts +3 -0
- package/src/styles/inline.ts +27 -148
- package/src/styles.css +1268 -369
- package/src/types.ts +3 -0
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import React, { useState, type SelectHTMLAttributes } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import type { BaseAiProps } from "../types";
|
|
4
|
+
import { ChevronDown, Loader2, Lock, Sparkles } from "lucide-react";
|
|
5
|
+
import type { AiRadius, AiSize, BaseAiProps } from "../types";
|
|
6
6
|
import { useAiCallText } from "../hooks/useAiCallText";
|
|
7
7
|
import { useAiModels } from "../hooks/useAiModels";
|
|
8
8
|
import { AiPromptPanel } from "./AiPromptPanel";
|
|
9
9
|
import { UsageToast, useUsageToast } from "./UsageToast";
|
|
10
10
|
import { LBSigninModal } from "./LBSigninModal";
|
|
11
|
-
import { aiStyles } from "../styles/inline";
|
|
12
11
|
import { handleAIError } from "../utils/errorHandler";
|
|
13
12
|
import { useLB } from "../context/LBAuthProvider";
|
|
13
|
+
import { useAiContext } from "../context/AiProvider";
|
|
14
14
|
|
|
15
15
|
export interface AiSelectProps
|
|
16
16
|
extends
|
|
17
17
|
Omit<BaseAiProps, "type">,
|
|
18
|
-
Omit<SelectHTMLAttributes<HTMLSelectElement>, "onValue"> {
|
|
18
|
+
Omit<SelectHTMLAttributes<HTMLSelectElement>, "onValue" | "size"> {
|
|
19
19
|
children: React.ReactNode;
|
|
20
20
|
uiMode?: "modal" | "drawer";
|
|
21
|
+
size?: AiSize;
|
|
22
|
+
radius?: AiRadius;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export function AiSelect({
|
|
24
|
-
baseUrl,
|
|
25
|
-
apiKeyId,
|
|
26
|
+
baseUrl: propBaseUrl,
|
|
27
|
+
apiKeyId: propApiKeyId,
|
|
26
28
|
uiMode = "modal",
|
|
29
|
+
size = "md",
|
|
30
|
+
radius = "full",
|
|
27
31
|
context,
|
|
28
32
|
model,
|
|
29
33
|
prompt,
|
|
@@ -38,7 +42,6 @@ export function AiSelect({
|
|
|
38
42
|
}: AiSelectProps) {
|
|
39
43
|
const [isOpen, setIsOpen] = useState(false);
|
|
40
44
|
const [showAuthModal, setShowAuthModal] = useState(false);
|
|
41
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
42
45
|
const { showUsageToast, toastData, toastKey, clearToast } = useUsageToast();
|
|
43
46
|
|
|
44
47
|
// Rendre l'authentification optionnelle
|
|
@@ -51,6 +54,20 @@ export function AiSelect({
|
|
|
51
54
|
lbStatus = undefined;
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
let ctxBaseUrl: string | undefined;
|
|
58
|
+
let ctxApiKeyId: string | undefined;
|
|
59
|
+
try {
|
|
60
|
+
const aiContext = useAiContext();
|
|
61
|
+
ctxBaseUrl = aiContext.baseUrl;
|
|
62
|
+
ctxApiKeyId = aiContext.apiKeyId;
|
|
63
|
+
} catch {
|
|
64
|
+
ctxBaseUrl = undefined;
|
|
65
|
+
ctxApiKeyId = undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const baseUrl = propBaseUrl ?? ctxBaseUrl;
|
|
69
|
+
const apiKeyId = propApiKeyId ?? ctxApiKeyId;
|
|
70
|
+
|
|
54
71
|
const { models } = useAiModels({
|
|
55
72
|
baseUrl,
|
|
56
73
|
apiKeyId,
|
|
@@ -99,69 +116,44 @@ export function AiSelect({
|
|
|
99
116
|
}
|
|
100
117
|
};
|
|
101
118
|
|
|
119
|
+
const sizeClass = `ai-size-${size}`;
|
|
120
|
+
const radiusClass = `ai-radius-${radius}`;
|
|
121
|
+
|
|
102
122
|
return (
|
|
103
|
-
<div
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
display: "flex",
|
|
138
|
-
alignItems: "center",
|
|
139
|
-
color: shouldShowSparkles ? "#6366f1" : "#ef4444",
|
|
140
|
-
}}
|
|
141
|
-
title={
|
|
142
|
-
shouldShowSparkles
|
|
143
|
-
? "Générer avec l'IA"
|
|
144
|
-
: "Se connecter pour utiliser l'IA"
|
|
145
|
-
}
|
|
146
|
-
disabled={disabled || loading}
|
|
147
|
-
>
|
|
148
|
-
{loading ? (
|
|
149
|
-
<svg
|
|
150
|
-
style={aiStyles.spinner}
|
|
151
|
-
width="16"
|
|
152
|
-
height="16"
|
|
153
|
-
viewBox="0 0 24 24"
|
|
154
|
-
fill="none"
|
|
155
|
-
stroke="currentColor"
|
|
156
|
-
>
|
|
157
|
-
<path d="M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48l2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48l2.83-2.83" />
|
|
158
|
-
</svg>
|
|
159
|
-
) : shouldShowSparkles ? (
|
|
160
|
-
<Sparkles size={16} />
|
|
161
|
-
) : (
|
|
162
|
-
<Lock size={16} />
|
|
163
|
-
)}
|
|
164
|
-
</button>
|
|
123
|
+
<div className={`ai-control-group ai-glow ${className || ""}`}>
|
|
124
|
+
<div className={`ai-shell ${sizeClass} ${radiusClass}`}>
|
|
125
|
+
<select
|
|
126
|
+
{...selectProps}
|
|
127
|
+
className={`ai-control ai-control-input ai-control-select ${sizeClass} ${radiusClass}`}
|
|
128
|
+
disabled={disabled || loading}
|
|
129
|
+
>
|
|
130
|
+
{children}
|
|
131
|
+
</select>
|
|
132
|
+
|
|
133
|
+
<span className="ai-control-select-chevron" aria-hidden="true">
|
|
134
|
+
<ChevronDown size={14} />
|
|
135
|
+
</span>
|
|
136
|
+
|
|
137
|
+
<button
|
|
138
|
+
className={`ai-control-action ai-spark ${sizeClass} ${radiusClass}`}
|
|
139
|
+
onClick={handleOpenPanel}
|
|
140
|
+
title={
|
|
141
|
+
shouldShowSparkles
|
|
142
|
+
? "Générer avec l'IA"
|
|
143
|
+
: "Se connecter pour utiliser l'IA"
|
|
144
|
+
}
|
|
145
|
+
disabled={disabled || loading}
|
|
146
|
+
type="button"
|
|
147
|
+
>
|
|
148
|
+
{loading ? (
|
|
149
|
+
<Loader2 size={16} className="ai-spinner" />
|
|
150
|
+
) : shouldShowSparkles ? (
|
|
151
|
+
<Sparkles size={16} />
|
|
152
|
+
) : (
|
|
153
|
+
<Lock size={16} />
|
|
154
|
+
)}
|
|
155
|
+
</button>
|
|
156
|
+
</div>
|
|
165
157
|
{isOpen && (
|
|
166
158
|
<AiPromptPanel
|
|
167
159
|
isOpen={isOpen}
|