@lastbrain/ai-ui-react 1.0.68 → 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 -668
- 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 -1313
- 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
package/dist/types.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ export type ToastType = {
|
|
|
4
4
|
code?: string;
|
|
5
5
|
};
|
|
6
6
|
export type UiMode = "modal" | "drawer";
|
|
7
|
+
export type AiSize = "sm" | "md" | "lg";
|
|
8
|
+
export type AiRadius = "none" | "sm" | "md" | "lg" | "full";
|
|
9
|
+
export type AiVariant = "default" | "light";
|
|
7
10
|
export interface BaseAiProps {
|
|
8
11
|
baseUrl?: string;
|
|
9
12
|
apiKeyId?: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AACF,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AACF,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AACxC,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AACxC,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAC5D,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
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.69",
|
|
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.53"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^19.2.0",
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import React, { useState, useRef, KeyboardEvent } from "react";
|
|
4
4
|
import { X, Sparkles, Lock } from "lucide-react";
|
|
5
|
-
import { aiStyles } from "../styles/inline";
|
|
6
5
|
import { AiPromptPanel } from "./AiPromptPanel";
|
|
7
6
|
import { LBSigninModal } from "./LBSigninModal";
|
|
8
7
|
import { useAiCallText } from "../hooks/useAiCallText";
|
|
@@ -10,10 +9,13 @@ import { useAiModels } from "../hooks/useAiModels";
|
|
|
10
9
|
import { useAiContext } from "../context/AiProvider";
|
|
11
10
|
import { useLB } from "../context/LBAuthProvider";
|
|
12
11
|
import { handleAIError } from "../utils/errorHandler";
|
|
12
|
+
import type { AiRadius, AiSize } from "../types";
|
|
13
13
|
|
|
14
14
|
export interface AiChipLabelProps {
|
|
15
15
|
children: React.ReactNode;
|
|
16
|
-
variant?: "default" | "
|
|
16
|
+
variant?: "default" | "selected" | "warning" | "success" | "danger";
|
|
17
|
+
size?: AiSize;
|
|
18
|
+
radius?: AiRadius;
|
|
17
19
|
className?: string;
|
|
18
20
|
style?: React.CSSProperties;
|
|
19
21
|
}
|
|
@@ -21,36 +23,23 @@ export interface AiChipLabelProps {
|
|
|
21
23
|
export function AiChipLabel({
|
|
22
24
|
children,
|
|
23
25
|
variant = "default",
|
|
26
|
+
size = "md",
|
|
27
|
+
radius = "full",
|
|
24
28
|
className,
|
|
25
29
|
style: customStyle,
|
|
26
30
|
}: AiChipLabelProps) {
|
|
27
|
-
const
|
|
28
|
-
default:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
warning: {
|
|
35
|
-
background: "#f59e0b10",
|
|
36
|
-
color: "#f59e0b",
|
|
37
|
-
borderColor: "#f59e0b30",
|
|
38
|
-
},
|
|
39
|
-
danger: {
|
|
40
|
-
background: "#ef444410",
|
|
41
|
-
color: "#ef4444",
|
|
42
|
-
borderColor: "#ef444430",
|
|
43
|
-
},
|
|
31
|
+
const variantClassMap: Record<string, string> = {
|
|
32
|
+
default: "",
|
|
33
|
+
selected: "ai-chip--selected",
|
|
34
|
+
warning: "ai-chip--success",
|
|
35
|
+
success: "ai-chip--success",
|
|
36
|
+
danger: "ai-chip--danger",
|
|
44
37
|
};
|
|
45
38
|
|
|
46
39
|
return (
|
|
47
40
|
<span
|
|
48
|
-
style={
|
|
49
|
-
|
|
50
|
-
...variantStyles[variant],
|
|
51
|
-
...customStyle,
|
|
52
|
-
}}
|
|
53
|
-
className={className}
|
|
41
|
+
style={customStyle}
|
|
42
|
+
className={`ai-chip ai-size-${size} ai-radius-${radius} ${variantClassMap[variant]} ${className || ""}`}
|
|
54
43
|
>
|
|
55
44
|
{children}
|
|
56
45
|
</span>
|
|
@@ -70,6 +59,8 @@ export interface AiChipInputProps {
|
|
|
70
59
|
// Props optionnelles pour override du contexte (si nécessaire)
|
|
71
60
|
baseUrl?: string;
|
|
72
61
|
apiKeyId?: string;
|
|
62
|
+
size?: AiSize;
|
|
63
|
+
radius?: AiRadius;
|
|
73
64
|
}
|
|
74
65
|
|
|
75
66
|
export function AiChipInput({
|
|
@@ -84,6 +75,8 @@ export function AiChipInput({
|
|
|
84
75
|
artifactTitle,
|
|
85
76
|
baseUrl: propBaseUrl,
|
|
86
77
|
apiKeyId: propApiKeyId,
|
|
78
|
+
size = "md",
|
|
79
|
+
radius = "full",
|
|
87
80
|
}: AiChipInputProps) {
|
|
88
81
|
const [inputValue, setInputValue] = useState("");
|
|
89
82
|
const [showPromptPanel, setShowPromptPanel] = useState(false);
|
|
@@ -199,92 +192,62 @@ Exemple de réponse attendue: javascript, react, frontend, api, development`;
|
|
|
199
192
|
onChange?.(updatedChips);
|
|
200
193
|
};
|
|
201
194
|
|
|
202
|
-
|
|
195
|
+
const sizeClass = `ai-size-${size}`;
|
|
196
|
+
const radiusClass = `ai-radius-${radius}`;
|
|
203
197
|
|
|
204
198
|
return (
|
|
205
199
|
<div className={className}>
|
|
206
200
|
{/* Input avec bouton génération */}
|
|
207
|
-
<div
|
|
208
|
-
<
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
201
|
+
<div className="ai-control-group ai-glow mb-2">
|
|
202
|
+
<div className={`ai-shell ${sizeClass} ${radiusClass}`}>
|
|
203
|
+
<input
|
|
204
|
+
ref={inputRef}
|
|
205
|
+
type="text"
|
|
206
|
+
value={inputValue}
|
|
207
|
+
onChange={(e) => setInputValue(e.target.value)}
|
|
208
|
+
onKeyDown={handleKeyDown}
|
|
209
|
+
placeholder={placeholder}
|
|
210
|
+
className={`ai-control ai-control-input ai-control-input--with-action ${sizeClass} ${radiusClass}`}
|
|
211
|
+
/>
|
|
212
|
+
<button
|
|
213
|
+
onClick={() => {
|
|
214
|
+
if (isAuthenticated) {
|
|
215
|
+
handleGenerateChips();
|
|
216
|
+
} else {
|
|
217
|
+
setShowSigninModal(true);
|
|
218
|
+
}
|
|
219
|
+
}}
|
|
220
|
+
className={`ai-control-action ai-spark ${sizeClass} ${radiusClass}`}
|
|
221
|
+
aria-label={isAuthenticated ? "Générer des tags avec l'IA" : "Connexion requise"}
|
|
222
|
+
title={
|
|
223
|
+
isAuthenticated
|
|
224
|
+
? "Générer des tags avec l'IA"
|
|
225
|
+
: "Se connecter pour utiliser l'IA"
|
|
226
226
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
top: "50%",
|
|
232
|
-
transform: "translateY(-50%)",
|
|
233
|
-
background: "none",
|
|
234
|
-
border: "none",
|
|
235
|
-
cursor: "pointer",
|
|
236
|
-
padding: "4px",
|
|
237
|
-
borderRadius: "4px",
|
|
238
|
-
display: "flex",
|
|
239
|
-
alignItems: "center",
|
|
240
|
-
color: isAuthenticated ? "#6366f1" : "#ef4444",
|
|
241
|
-
}}
|
|
242
|
-
title={
|
|
243
|
-
isAuthenticated
|
|
244
|
-
? "Générer des tags avec l'IA"
|
|
245
|
-
: "Se connecter pour utiliser l'IA"
|
|
246
|
-
}
|
|
247
|
-
>
|
|
248
|
-
{isAuthenticated ? <Sparkles size={16} /> : <Lock size={16} />}
|
|
249
|
-
</button>
|
|
227
|
+
>
|
|
228
|
+
{isAuthenticated ? <Sparkles size={16} /> : <Lock size={16} />}
|
|
229
|
+
</button>
|
|
230
|
+
</div>
|
|
250
231
|
</div>
|
|
251
232
|
|
|
252
233
|
{/* Chips affichées */}
|
|
253
234
|
{value.length > 0 && (
|
|
254
|
-
<div
|
|
255
|
-
{value.map((chip, index) =>
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
paddingRight: "6px",
|
|
266
|
-
}}
|
|
235
|
+
<div className="ai-chip-input">
|
|
236
|
+
{value.map((chip, index) => (
|
|
237
|
+
<div
|
|
238
|
+
key={index}
|
|
239
|
+
className={`ai-chip ai-chip--with-close ${sizeClass} ${radiusClass}`}
|
|
240
|
+
>
|
|
241
|
+
<span>{chip}</span>
|
|
242
|
+
<button
|
|
243
|
+
onClick={() => removeChip(index)}
|
|
244
|
+
className="ai-chip-remover"
|
|
245
|
+
title="Supprimer"
|
|
267
246
|
>
|
|
268
|
-
<
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
background: "none",
|
|
273
|
-
border: "none",
|
|
274
|
-
cursor: "pointer",
|
|
275
|
-
padding: "0",
|
|
276
|
-
display: "flex",
|
|
277
|
-
alignItems: "center",
|
|
278
|
-
color: "currentColor",
|
|
279
|
-
opacity: 0.7,
|
|
280
|
-
}}
|
|
281
|
-
title="Supprimer"
|
|
282
|
-
>
|
|
283
|
-
<X size={14} />
|
|
284
|
-
</button>
|
|
285
|
-
</div>
|
|
286
|
-
);
|
|
287
|
-
})}
|
|
247
|
+
<X size={14} />
|
|
248
|
+
</button>
|
|
249
|
+
</div>
|
|
250
|
+
))}
|
|
288
251
|
</div>
|
|
289
252
|
)}
|
|
290
253
|
|