@lastbrain/ai-ui-react 1.0.3 → 1.0.6

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": "@lastbrain/ai-ui-react",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "Headless React components for LastBrain AI UI Kit",
5
5
  "private": false,
6
6
  "type": "module",
@@ -12,7 +12,8 @@
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs",
14
14
  "default": "./dist/index.js"
15
- }
15
+ },
16
+ "./styles.css": "./dist/styles.css"
16
17
  },
17
18
  "release": {
18
19
  "type": "public"
@@ -37,13 +38,16 @@
37
38
  "dist",
38
39
  "src"
39
40
  ],
40
- "sideEffects": false,
41
+ "sideEffects": [
42
+ "*.css",
43
+ "dist/styles.css"
44
+ ],
41
45
  "peerDependencies": {
42
46
  "react": ">=18.0.0",
43
47
  "react-dom": ">=18.0.0"
44
48
  },
45
49
  "dependencies": {
46
- "@lastbrain/ai-ui-core": "^1.0.3"
50
+ "@lastbrain/ai-ui-core": "1.0.5"
47
51
  },
48
52
  "devDependencies": {
49
53
  "@types/react": "^19.2.0",
@@ -54,7 +58,7 @@
54
58
  },
55
59
  "scripts": {
56
60
  "dev": "tsc -p tsconfig.json --watch",
57
- "build": "tsc -p tsconfig.json",
61
+ "build": "tsc -p tsconfig.json && cp src/styles.css dist/styles.css && cp styles.d.ts dist/styles.d.ts",
58
62
  "lint": "eslint ."
59
63
  }
60
64
  }
@@ -0,0 +1,198 @@
1
+ "use client";
2
+
3
+ import type { AiStatus } from "@lastbrain/ai-ui-core";
4
+ import { useState } from "react";
5
+
6
+ export interface AiStatusButtonProps {
7
+ status: AiStatus | null;
8
+ loading?: boolean;
9
+ className?: string;
10
+ }
11
+
12
+ export function AiStatusButton({
13
+ status,
14
+ loading = false,
15
+ className = "",
16
+ }: AiStatusButtonProps) {
17
+ const [showTooltip, setShowTooltip] = useState(false);
18
+
19
+ if (loading) {
20
+ return (
21
+ <button
22
+ className={`ai-status-button ai-status-button--loading ${className}`}
23
+ disabled
24
+ >
25
+ <svg
26
+ className="ai-spinner"
27
+ width="16"
28
+ height="16"
29
+ viewBox="0 0 24 24"
30
+ fill="none"
31
+ stroke="currentColor"
32
+ >
33
+ <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" />
34
+ </svg>
35
+ </button>
36
+ );
37
+ }
38
+
39
+ if (!status) {
40
+ return (
41
+ <button
42
+ className={`ai-status-button ai-status-button--error ${className}`}
43
+ onMouseEnter={() => setShowTooltip(true)}
44
+ onMouseLeave={() => setShowTooltip(false)}
45
+ >
46
+ <svg
47
+ width="16"
48
+ height="16"
49
+ viewBox="0 0 24 24"
50
+ fill="none"
51
+ stroke="currentColor"
52
+ >
53
+ <polyline points="22 12 18 12 15 21 9 3 6 12 2 12" />
54
+ </svg>
55
+ {showTooltip && <div className="ai-tooltip">No status available</div>}
56
+ </button>
57
+ );
58
+ }
59
+
60
+ return (
61
+ <div className="ai-status-button-wrapper">
62
+ <button
63
+ className={`ai-status-button ai-status-button--success ${className}`}
64
+ onMouseEnter={() => setShowTooltip(true)}
65
+ onMouseLeave={() => setShowTooltip(false)}
66
+ >
67
+ <svg
68
+ width="16"
69
+ height="16"
70
+ viewBox="0 0 24 24"
71
+ fill="none"
72
+ stroke="currentColor"
73
+ >
74
+ <polyline points="22 12 18 12 15 21 9 3 6 12 2 12" />
75
+ </svg>
76
+ </button>
77
+
78
+ {showTooltip && (
79
+ <div className="ai-tooltip ai-tooltip--status">
80
+ <div className="ai-tooltip__header">API Status</div>
81
+
82
+ <div className="ai-tooltip__section">
83
+ <div className="ai-tooltip__row">
84
+ <span className="ai-tooltip__label">API Key:</span>
85
+ <span className="ai-tooltip__value">{status.api_key.name}</span>
86
+ </div>
87
+ <div className="ai-tooltip__row">
88
+ <span className="ai-tooltip__label">Env:</span>
89
+ <span className="ai-tooltip__value">{status.api_key.env}</span>
90
+ </div>
91
+ <div className="ai-tooltip__row">
92
+ <span className="ai-tooltip__label">Rate Limit:</span>
93
+ <span className="ai-tooltip__value">
94
+ {status.api_key.rate_limit_rpm} req/min
95
+ </span>
96
+ </div>
97
+ </div>
98
+
99
+ <div className="ai-tooltip__section">
100
+ <div className="ai-tooltip__subtitle">Balance</div>
101
+ <div className="ai-tooltip__row">
102
+ <span className="ai-tooltip__label">Total:</span>
103
+ <span className="ai-tooltip__value ai-tooltip__value--bold">
104
+ {status.balance.total.toLocaleString()}
105
+ </span>
106
+ </div>
107
+ <div className="ai-tooltip__row">
108
+ <span className="ai-tooltip__label">Purchased:</span>
109
+ <span className="ai-tooltip__value">
110
+ {status.balance.purchased.toLocaleString()}
111
+ </span>
112
+ </div>
113
+ <div className="ai-tooltip__row">
114
+ <span className="ai-tooltip__label">Quota:</span>
115
+ <span className="ai-tooltip__value">
116
+ {status.balance.quota.toLocaleString()}
117
+ </span>
118
+ </div>
119
+ </div>
120
+
121
+ <div className="ai-tooltip__section">
122
+ <div className="ai-tooltip__subtitle">Plan</div>
123
+ <div className="ai-tooltip__row">
124
+ <span className="ai-tooltip__label">Type:</span>
125
+ <span className="ai-tooltip__value ai-tooltip__value--capitalize">
126
+ {status.quota.plan}
127
+ </span>
128
+ </div>
129
+ <div className="ai-tooltip__row">
130
+ <span className="ai-tooltip__label">Remaining:</span>
131
+ <span className="ai-tooltip__value">
132
+ {status.quota.remaining_quota.toLocaleString()} /{" "}
133
+ {status.quota.effective_quota.toLocaleString()}
134
+ </span>
135
+ </div>
136
+ <div className="ai-tooltip__row">
137
+ <span className="ai-tooltip__label">Status:</span>
138
+ <span
139
+ className={`ai-tooltip__value ${status.quota.is_active ? "ai-tooltip__value--success" : "ai-tooltip__value--warning"}`}
140
+ >
141
+ {status.quota.is_active ? "Active" : "Inactive"}
142
+ </span>
143
+ </div>
144
+ </div>
145
+
146
+ <div className="ai-tooltip__section">
147
+ <div className="ai-tooltip__subtitle">Storage</div>
148
+ <div className="ai-tooltip__row">
149
+ <span className="ai-tooltip__label">Database:</span>
150
+ <span className="ai-tooltip__value">
151
+ {status.storage.db_mb.toFixed(2)} MB
152
+ </span>
153
+ </div>
154
+ <div className="ai-tooltip__row">
155
+ <span className="ai-tooltip__label">Files:</span>
156
+ <span className="ai-tooltip__value">
157
+ {status.storage.files_mb.toFixed(2)} MB
158
+ </span>
159
+ </div>
160
+ <div className="ai-tooltip__row">
161
+ <span className="ai-tooltip__label">Total:</span>
162
+ <span className="ai-tooltip__value ai-tooltip__value--bold">
163
+ {(status.storage.db_mb + status.storage.files_mb).toFixed(2)} MB
164
+ </span>
165
+ </div>
166
+ </div>
167
+
168
+ <div className="ai-tooltip__section ai-tooltip__actions">
169
+ <a
170
+ href="https://ai.lastbrain.io/fr/auth/dashboard"
171
+ target="_blank"
172
+ rel="noopener noreferrer"
173
+ className="ai-tooltip__link"
174
+ >
175
+ Dashboard
176
+ </a>
177
+ <a
178
+ href="https://ai.lastbrain.io/fr/auth/billing"
179
+ target="_blank"
180
+ rel="noopener noreferrer"
181
+ className="ai-tooltip__link"
182
+ >
183
+ History
184
+ </a>
185
+ <a
186
+ href="https://ai.lastbrain.io/fr/auth/billing"
187
+ target="_blank"
188
+ rel="noopener noreferrer"
189
+ className="ai-tooltip__link"
190
+ >
191
+ Settings
192
+ </a>
193
+ </div>
194
+ </div>
195
+ )}
196
+ </div>
197
+ );
198
+ }
package/src/index.ts CHANGED
@@ -21,3 +21,4 @@ export * from "./components/AiSelect";
21
21
  export * from "./components/AiChipLabel";
22
22
  export * from "./components/AiImageButton";
23
23
  export * from "./components/AiSettingsButton";
24
+ export * from "./components/AiStatusButton";